# PDFluent for Rust — install with cargo

Source: https://pdfluent.com/docs/rust/

Channel guide

# PDFluent for Rust

Generally available Updated 2026-05-14

[Star on GitHub](https://github.com/pdfluent/pdfluent-sdk)

### On this page

- Install
- Smoke test
- Try XFA flattening in the browser
- Structured extraction (Preview)
- What this is good for
- Current limitations
- Licensing
- Where to go next

## Install

One command. The package is on [crates.io](https://crates.io/crates/pdfluent) today.

`cargo add pdfluent@1.5.0`

## Smoke test

Open a PDF, print the page count. The example below is the smallest useful program — copy, paste, run.

rust

```
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](https://pdfluent.com/playground/xfa-flatten/) 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)

Preview Structured 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, written in Rust, no models, runs everywhere including WebAssembly) and `balanced` (Preview, native only).
- Balanced needs the `ort-layout` and `ort-tables` cargo features plus models installed with `pdfluent models install layout tables`.
- Docling JSON: `doc.extract_docling(name, &opts)?`.
- Page window: `ExtractOptions::window(first, count)`; the document is still read whole.

rust

```
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](https://pdfluent.com/docs/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](https://pdfluent.com/docs/licensing/).

## Where to go next

- [Open crates.io Browse versions and the published API.](https://crates.io/crates/pdfluent)
- [View pricing Annual licences with perpetual-fallback.](https://pdfluent.com/pricing/)
- [Contact licensing We respond within one business day.](mailto:hello@pdfluent.com?subject=Licensing)
- [All language channels The hub lists all language channels.](https://pdfluent.com/docs/)
