Solutions

Generate PDFs programmatically in Rust.

Create invoices, receipts, reports, and templated documents from data. Pure Rust, no Java, no Python, no native dependencies.

Code example

rust
use pdfluent::{Document, Page, Font, Color};

fn generate_invoice(order: &Order) -> Vec<u8> {
    let mut doc = Document::new();
    let mut page = Page::a4();

    // Title
    page.add_text(
        &format!("Invoice #{}", order.id),
        Font::helvetica_bold(24),
        Position::new(50.0, 780.0),
    );

    // Line items table
    let mut y = 700.0;
    for item in &order.items {
        page.add_text(
            &item.description,
            Font::helvetica(11),
            Position::new(50.0, y),
        );
        page.add_text(
            &format!("€ {:.2}", item.price),
            Font::helvetica(11),
            Position::new(480.0, y),
        );
        y -= 20.0;
    }

    // Footer
    page.add_text(
        &format!("Total: € {:.2}", order.total),
        Font::helvetica_bold(13),
        Position::new(50.0, y - 20.0),
    );

    doc.add_page(page);
    doc.save_bytes()
}

Run cargo add pdfluent to get started.

What it does

Generate from data

Produce invoices, receipts, delivery notes, and reports directly from your application data. Pass a struct or JSON value; PDFluent lays out the document. No intermediate HTML, no headless browser, no external service call.

Template-based generation

Define reusable page templates with fixed layout regions — headers, footers, columns, tables — and fill them with dynamic content at runtime. Templates are plain Rust structs, versioned alongside your code.

No dependencies, works everywhere

PDFluent is a pure Rust crate with no C FFI, no Java, and no Python runtime. It compiles on Linux, macOS, Windows, and to wasm32-unknown-unknown. Deploy to AWS Lambda, Cloudflare Workers, or any container without extra system packages.

Full typography control

Embed TTF and OTF fonts, control kerning, line height, and text wrapping. Supports Unicode including RTL scripts. Subset fonts to keep file sizes small.

Tables and grids

Build structured tables with column alignment, cell borders, background colors, and automatic row pagination. Tables that overflow a page are split across pages automatically.

Images and vector graphics

Embed PNG, JPEG, and WebP images. Draw lines, rectangles, and paths for borders, dividers, and charts. All coordinates use the PDF user-space coordinate system.

Deployment options

AWS LambdaCloudflare Workers (WASM)Docker / KubernetesBare metal serversDenoWebAssembly (browser)

Frequently asked questions