IronSoftwareA contractor billing service written in Rust fills an HTML template with hours, a tax line and...
Hours, a tax line and payment terms go into an HTML template in a contractor billing service written in Rust, and the filled template becomes invoice-0042.pdf. The template is the easy part to maintain, and the renderer behind it decides how far that template can grow.
IronPDF for Rust is one of the editions we are building, and it is coming soon, with early-access sign-up. Until it opens, the invoice runs through printpdf.
We work at Iron Software, and the end of this article covers our library, IronPDF.
It parses the HTML with its built-in layout engine and returns the PDF as bytes. The printpdf crate is an MIT-licensed Rust library, also built for WebAssembly, that creates, reads, writes and renders PDF documents. It writes PDF operations directly, and its HTML layout, built on azul-layout and xmlparser, sits behind the crate's html feature, which version 0.13.0 turns on by default.
use printpdf::*;
use std::collections::BTreeMap;
fn main() {
// The invoice template, with its day rows and tax line, as one HTML string.
let html = r#"
<html>
<body style="padding:10mm">
<p>Invoice 0042</p>
<table>
<tr><td>Mon 16 Nov</td><td>6.5 h</td><td>552.50</td></tr>
<tr><td>Tue 17 Nov</td><td>7.0 h</td><td>595.00</td></tr>
<tr><td>Tax</td><td>8%</td><td>91.80</td></tr>
</table>
<p>Payment terms: net 30 days</p>
</body>
</html>
"#;
// Page size comes from the options, because the CSS @page rule is not parsed.
let images = BTreeMap::new();
let fonts = BTreeMap::new();
let options = GeneratePdfOptions {
page_width: Some(210.0),
page_height: Some(297.0),
..Default::default()
};
// from_html returns an Err when the input will not lay out.
let mut warnings = Vec::new();
let pdf_bytes = PdfDocument::from_html(html, &images, &fonts, &options, &mut warnings)
.unwrap()
.save(&PdfSaveOptions::default(), &mut warnings);
}
A string goes in and bytes come out, ready to write to invoice-0042.pdf. A production service matches on the Err from from_html in place of calling unwrap.
It covers basic layouts, and the project lists it as experimental. The README places XHTML layout among its experimental features and notes that HTML-to-PDF works for tables, page breaks and footnotes but is still evolving. In 2025, HTML rendering was reported broken on the tracker, and in one report every line of an example landed on a single line. The maintainer, fschutt, closed that report on November 25, 2026, saying the original input works on the project's demo page.
Several limits shape an invoice template. Page size and margins come from GeneratePdfOptions, and the CSS @page rule is not parsed apart from its @footnote area. Table rows are not split across pages. An invoice logo given only a CSS width may end up without a height and be dropped from the page. File attachments are outside printpdf's supported feature list, which matters when a customer asks for an e-invoice with an XML file attached.
It involves placing every cell with PDF operations at coordinates the code chooses. The code opens a text section with Op::StartTextSection, sets the cursor with Op::SetTextCursor, picks a font and size with Op::SetFont, writes each cell with Op::ShowText and closes with Op::EndTextSection. The rules between rows and around the tax line are lines and rectangles at chosen coordinates, and save() warns when text-showing operations sit outside a text section, since most viewers drop that text. Every column edge is a number the team maintains.
With ops, text, lines and shapes go exactly where the code puts them, in millimeters or points. It embeds fonts with Unicode support and subsets them, which keeps a one-page invoice small. When the layout engine is used, automatic page breaks and break-inside: avoid are honored, and its test suite exercises flexbox. It also reads existing PDFs and offers experimental PDF/A-1b and PDF/A-2b output. Version 0.13.0 was published on November 25, 2026.
To full HTML rendering, since the Rust edition is designed to take the whole template, CSS and scripts included, as its input. The product page promises that the edition will let Rust programs turn HTML into PDFs and edit existing ones without leaving Rust, so the designer's CSS would drive the invoice page.
Alongside conversion, the page lists headers and footers, watermarks, annotations and bookmarks, merging and splitting, form filling and digital signatures, text and table extraction, comparison, and password, redaction, compression and PDF/A work. A Rust service would host the engine in its own process, since the page says it runs inside the application with nothing extra to deploy.
A sample invoice, a list of what the template needs next and an early-access registration, so the edition can be measured on its first build.
invoice-0042 and its heavier variants ready as the first test.Facts about printpdf in this article rest on its repository, README, HTML documentation, issue tracker and crates.io record. Sign-up for early access is on the IronPDF for Rust page on ironpdf.com, and the template we would bring first is the one that has outgrown basic layout.
Drafted with AI. On November 26, 2026, the printpdf calls and limits were checked against its source, README and HTML documentation at tag v0.13.0, the release history against its crates.io record and issue tracker, and the IronPDF for Rust claims against its product page.
printpdf, Rust, azul-layout, xmlparser and crates.io are trademarks of their respective owners, we have no affiliation with any of them, and the facts above come from the printpdf repository, README, HTML documentation, issue tracker and crates.io record and the IronPDF for Rust page on ironpdf.com.