Install
One command. The package is on crates.io today.
cargo add pdfluent@1.1.0Smoke test
Open a PDF, print the page count. The example below is the smallest useful program — copy, paste, run.
use pdfluent::PdfDocument;
fn main() -> pdfluent::Result<()> {
let doc = PdfDocument::open("invoice.pdf")?;
println!("{} pages", doc.page_count());
Ok(())
}Try XFA flattening in the browser
Before writing any Rust, you can see the XFA flattener work on a real form: the XFA Flatten playground demo runs the same code as this SDK, entirely in your browser via WebAssembly — nothing is uploaded. Load an XFA form and download the flattened, static result.
Structured extraction (Preview)
PreviewStructured extraction in Rust returns Markdown from doc.extract_markdown, blocks from doc.extract_blocks, and Docling-shaped JSON from doc.extract_docling. Structured extraction ships as Preview: output quality is still improving and the API may change in a minor release.
- Tiers:
fast(default, the engine alone, pure Rust, no models, runs everywhere including WebAssembly) andbalanced(Preview, native only). - Balanced needs the
ort-layoutandort-tablescargo features plus models installed withpdfluent models install layout tables. - Docling JSON:
doc.extract_docling(name, &opts)?. - Page window:
ExtractOptions::window(first, count); the document is still read whole.
use pdfluent::prelude::*;
let doc = PdfDocument::open("report.pdf")?;
// The whole document as markdown: headings, lists and tables, in reading
// order, with a comment where the page changes.
let markdown = doc.extract_markdown(&ExtractOptions::default())?;
std::fs::write("report.md", &markdown).ok();
// Or the blocks themselves, to chunk and cite with.
for block in doc.extract_blocks(&ExtractOptions::default())? {
if let BlockKind::Heading { level } = block.kind {
println!("h{level} p{} {}", block.page + 1, block.text);
}
}What this is good for
- Server-side document pipelines
- Native CLI tooling
- Embedding the SDK in Rust services and workers
Current limitations
This list is honest, not exhaustive. The site-wide list lives at Known limitations.
- XFA rendering fidelity is improving; complex dynamic forms may render with visual deltas.
- PDF/A conversion currently covers PDF/A-1b, 2b, and 3b. Uncommon profiles are scoped for later releases.
Licensing
PDFluent is published under the AGPLv3 and is complete under it. A yearly commercial licence removes the obligation to publish your own source; nothing in the build differs and nothing is activated, so a lapsed licence breaks nothing you have shipped. Details on the licensing page.