Expand description
§ironpress
Pure Rust HTML/CSS/Markdown to PDF converter. No browser, no system dependencies.
ironpress converts HTML (with CSS) and Markdown into PDF documents using a built-in layout engine. Unlike other Rust PDF crates, it does not shell out to headless Chrome or wkhtmltopdf.
§Features
- All common HTML elements: headings, paragraphs, lists, tables, images, links, semantic sections
- CSS support: selectors, flexbox, grid, floats, positioning, transforms, gradients, custom properties
- Built-in Markdown parser (no external dependencies)
- Custom TrueType font embedding
- JPEG and PNG images (data URIs and local files)
- Streaming output via
std::io::Write - Async file I/O via optional
tokiointegration - HTML sanitization enabled by default
§Quick start
let pdf = ironpress::html_to_pdf("<h1>Hello</h1><p>World</p>").unwrap();
assert!(pdf.starts_with(b"%PDF"));§Markdown
let pdf = ironpress::markdown_to_pdf("# Hello\n\nWorld").unwrap();
assert!(pdf.starts_with(b"%PDF"));§Builder API
use ironpress::{HtmlConverter, PageSize, Margin};
let pdf = HtmlConverter::new()
.page_size(PageSize::LETTER)
.margin(Margin::uniform(54.0))
.sanitize(false)
.convert("<h1>Hello</h1>")
.unwrap();§Streaming output
let mut buf = Vec::new();
ironpress::html_to_pdf_writer("<h1>Hello</h1>", &mut buf).unwrap();
assert!(buf.starts_with(b"%PDF"));§Custom fonts
use ironpress::HtmlConverter;
let ttf = std::fs::read("fonts/MyFont.ttf").unwrap();
let pdf = HtmlConverter::new()
.add_font("MyFont", ttf)
.convert(r#"<p style="font-family: MyFont">Custom text</p>"#)
.unwrap();Re-exports§
pub use error::IronpressError;pub use types::Margin;pub use types::PageSize;
Modules§
Structs§
- Html
Converter - Builder for HTML-to-PDF conversion with custom options.
Functions§
- convert_
file - Convert an HTML file to a PDF file using default settings.
- convert_
markdown_ file - Convert a Markdown file to a PDF file using default settings.
- html_
to_ pdf - Convert an HTML string to PDF bytes using default settings (A4, 1-inch margins).
- html_
to_ pdf_ writer - Convert an HTML string to PDF, writing output to any
std::io::Writeimplementation. - markdown_
to_ pdf - Convert a Markdown string to PDF bytes using default settings (A4, 1-inch margins).
- markdown_
to_ pdf_ writer - Convert a Markdown string to PDF, writing output to any
std::io::Writeimplementation.