Skip to main content

Crate pdf_min

Crate pdf_min 

Source
Expand description

This crate implements minimal conversion from HTML to PDF.

ToDo: Maybe html tables.

§Test example

   use pdf_min::*;
   let source = format!("
<html>
<head>
  <title>Rust is Great</title>
</head>
<body>
<h1>Important Notice&excl;</h1>
<p>Hello <b>something bold</b> ok</p>
<p>Hi <i>italic test</i>
<p>Hi <i><b>bold italic test</b> ok</i>
<p>Hi <sup>sup test</sup> ok
<p>Hi <sub>sub text</sub> ok
<p>{}
</body>
</html>
","Some text £100 €200 to <b>cause</b> Line <i>and</i> Page <b><i>wrapping</i></b>. ".repeat(200));
   let mut w = Writer::default();
   w.b.nocomp = true; // w.fonts = font::times();
   w.line_pad = 8; // Other Writer default values could be adjusted here.
   html(&mut w, source.as_bytes());
   let bytes = w.finish();

   use std::fs::File;
   use std::io::prelude::*;

   let mut file = File::create("test.pdf").unwrap();
   file.write_all(bytes).unwrap();

Re-exports§

pub use html::html;
pub use writer::Writer;

Modules§

basic
Low level PDF writer.
font
PDF fonts.
html
Conversion from HTML to PDF.
image
PDF images.
metric
Character sizes for standard fonts.
page
PDF page.
writer
High level PDF writer.

Type Aliases§

MPx
1/1000 of a page unit (for text width calculations)
Px
Page unit