Skip to main content

pdf_min/
lib.rs

1//! This crate implements minimal conversion from HTML to PDF.
2//!
3//! ToDo:
4//! Maybe html tables.
5//!
6//!# Test example
7//!
8//! ```
9//!    use pdf_min::*;
10//!    let source = format!("
11//!<html>
12//!<head>
13//!   <title>Rust is Great</title>
14//!</head>
15//!<body>
16//!<h1>Important Notice&excl;</h1>
17//!<p>Hello <b>something bold</b> ok</p>
18//!<p>Hi <i>italic test</i>
19//!<p>Hi <i><b>bold italic test</b> ok</i>
20//!<p>Hi <sup>sup test</sup> ok
21//!<p>Hi <sub>sub text</sub> ok
22//!<p>{}
23//!</body>
24//!</html>
25//!","Some text £100 €200 to <b>cause</b> Line <i>and</i> Page <b><i>wrapping</i></b>. ".repeat(200));
26//!    let mut w = Writer::default();
27//!    w.b.nocomp = true; // w.fonts = font::times();
28//!    w.line_pad = 8; // Other Writer default values could be adjusted here.
29//!    html(&mut w, source.as_bytes());
30//!    let bytes = w.finish();
31//!
32//!    use std::fs::File;
33//!    use std::io::prelude::*;
34//!
35//!    let mut file = File::create("test.pdf").unwrap();
36//!    file.write_all(bytes).unwrap();
37//! ```
38
39#![forbid(unsafe_code)]
40#![warn(missing_docs)]
41
42/// Low level PDF writer.
43pub mod basic;
44/// PDF fonts.
45pub mod font;
46/// Conversion from HTML to PDF.
47pub mod html;
48/// PDF images.
49pub mod image;
50/// Character sizes for standard fonts.
51pub mod metric;
52/// PDF page.
53pub mod page;
54/// High level PDF writer.
55pub mod writer;
56
57pub use html::html;
58pub use writer::Writer;
59
60use basic::*;
61use font::*;
62use image::*;
63use page::*;
64use writer::*;
65
66/// Page unit
67pub type Px = i32;
68/// 1/1000 of a page unit (for text width calculations)
69pub type MPx = i64;