ironpress-0.1.0 has been yanked.
ironpress
Pure Rust HTML/CSS-to-PDF converter — no browser, no external dependencies.
Every existing Rust crate that converts HTML to PDF shells out to headless Chrome or wkhtmltopdf. ironpress does it natively with a built-in layout engine, producing valid PDFs from HTML with inline CSS.
Quick Start
use html_to_pdf;
let pdf_bytes = html_to_pdf.unwrap;
write.unwrap;
With Options
use ;
let pdf = new
.page_size
.margin
.convert
.unwrap;
File Conversion
convert_file.unwrap;
Supported HTML Elements
| Element | Rendering |
|---|---|
<h1> - <h6> |
Headings with default sizes and bold |
<p>, <div> |
Block containers |
<strong>, <b> |
Bold text |
<em>, <i> |
Italic text |
<u> |
Underlined text |
<a> |
Colored underlined text |
<br> |
Line break |
<hr> |
Horizontal rule |
<ul>, <ol>, <li> |
Lists |
<table>, <tr>, <td>, <th> |
Tables |
<span> |
Inline container |
Supported CSS Properties (inline style="...")
font-size, font-weight, font-style, color, background-color, margin, padding, text-align, text-decoration, line-height, page-break-before, page-break-after
Colors: named colors, #hex, rgb().
Security
HTML is sanitized by default before conversion:
<script>,<iframe>,<object>,<embed>,<form>tags are stripped- Event handlers (
onclick,onload, etc.) are removed javascript:URLs are neutralized- Input size and nesting depth are limited
Sanitization can be disabled with .sanitize(false) if you trust the input.
How It Works
HTML string → Parse (html5ever) → Style resolution → Layout engine → PDF generation
- Parse HTML into a DOM tree using html5ever
- Resolve styles by merging default tag styles with inline CSS
- Layout elements with text wrapping, page breaks, and box model
- Render to PDF using built-in Helvetica fonts (no font embedding needed)
License
MIT