Generate thousands of invoices, process incoming PDFs, fill forms, add watermarks, and run PDF pipelines in CI/CD — all from a single Rust binary with no external dependencies.
use pdfluent::{PdfDocument, WatermarkOptions};
fn main() -> pdfluent::Result<()> {
let mut doc = PdfDocument::open("template.pdf")?;
doc.form_mut()
.set_text("customer_name", "ACME Corp")?
.set_text("date", "2026-01-15")?;
doc.add_watermark("PROCESSED", WatermarkOptions::centered().opacity(0.15))?;
doc.save("filled.pdf")?;
Ok(())
}Run cargo add [email protected] to get started.
PDFluent integrates with Rayon for data-parallel processing. Document types are Send + Sync. Distribute work across all available CPU cores without any shared mutable state or locking.
Chain operations — merge, fill, watermark, sign, compress, validate — in a typed pipeline. Each step receives a Document and returns a Document. Compose steps at runtime from configuration without recompiling.
Operations like watermarking and form-filling are designed to be idempotent: running them twice on the same document produces the same result. This simplifies retry logic and makes pipelines safe to replay after failures.
Define a PDF template with fillable fields, then drive generation from a data source — a CSV, database query, or API response. PDFluent stamps data into each document and saves it without rendering to intermediate formats.
Use Rayon's collect-errors pattern to process an entire directory and collect all errors without short-circuiting. Inspect which documents failed and why, then replay only the failed subset.
PDFluent compiles to a single static binary with no runtime dependencies. Drop it into any Docker image, GitHub Actions runner, or Lambda function. Use exit codes and stdout/stderr for standard pipeline integration.