quality="auto" is the default extraction tier: table structure, the document's own heading levels and OCR for pages without a text layer. Pass quality="fast" to keep the 1.2 output. On opendataloader-bench SDK 1.4.0 scores 0.9282 overall.* Auto needs a one-time model install, and OCR of scanned pages needs Tesseract on the machine. Release post · Benchmark results*Submitted to the benchmark repository, PR #37 and #38, not on its public leaderboard yet. Measured with the benchmark's own harness on its 200 documents; final macOS arm64 release wheel; other engines as published in its README, not re-run by us. Full caveats on the benchmarks page.# Rust
cargo add pdfluent@1.4.0
# Python
pip install pdfluent==1.4.0
# Node.js
npm install @pdfluent/node
# Models for the auto and balanced tiers
pdfluent models install layout tablesuse pdfluent::{ExtractOptions, PdfDocument, Quality};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let doc = PdfDocument::open("report.pdf")?;
let markdown = doc.extract_markdown(&ExtractOptions::default())?;
let blocks = doc.extract_blocks(&ExtractOptions::default())?;
println!("{} blocks", blocks.len());
// balanced: needs the ort-layout/ort-tables features and installed models
let tables = doc.extract_markdown(&ExtractOptions::default().with_quality(Quality::Balanced))?;
println!("{markdown}\n{tables}");
Ok(())
}PdfDocument::open takes a path. extract_markdown returns Markdown (Preview); extract_blocks returns a Vec<Block> (Preview). The default options use the fast tier, which runs the engine alone with no models.
use pdfluent::{ExtractOptions, PdfDocument, Quality};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let doc = PdfDocument::open("report.pdf")?;
let markdown = doc.extract_markdown(&ExtractOptions::default())?;
let blocks = doc.extract_blocks(&ExtractOptions::default())?;
println!("{} blocks", blocks.len());
Ok(())
}Document is a context manager. extract_markdown returns Markdown (Preview); extract_words returns words with boxes (Preview); iter_chunks yields chunks with a .text attribute (Preview). Structured extraction is Preview.
from pdfluent import Document
from pdfluent.chunks import iter_chunks
with Document("report.pdf") as doc:
md = doc.extract_markdown() # fast tier, no models
words = doc.extract_words()
for chunk in iter_chunks(doc, mode="markdown"):
print(chunk.text)PdfDocument.open takes a buffer. extractMarkdown returns Markdown (Preview); iterChunks yields chunks with a .text attribute (Preview). Structured extraction is Preview.
const fs = require("node:fs");
const { PdfDocument, iterChunks } = require("@pdfluent/node");
const doc = PdfDocument.open(fs.readFileSync("report.pdf"));
const md = doc.extractMarkdown();
for (const chunk of iterChunks(doc, { mode: "markdown" })) {
console.log(chunk.text);
}from pdfluent import Document
from pdfluent.chunks import iter_chunks
with Document("report.pdf") as doc:
md = doc.extract_markdown() # fast tier, no models
for chunk in iter_chunks(doc, mode="markdown"):
print(chunk.text)iter_chunks takes a Document and a mode ("blocks" or "markdown") and yields chunks with a .text attribute. Structured extraction is Preview.
from pdfluent import Document
from pdfluent.chunks import iter_chunks
with Document("report.pdf") as doc:
for chunk in iter_chunks(doc, mode="markdown"):
print(chunk.text)iterChunks is exported from @pdfluent/node. It takes a document and an options object with mode: "markdown" and yields chunks with a .text attribute. Structured extraction is Preview.
const fs = require("node:fs");
const { PdfDocument, iterChunks } = require("@pdfluent/node");
const doc = PdfDocument.open(fs.readFileSync("report.pdf"));
for (const chunk of iterChunks(doc, { mode: "markdown" })) {
console.log(chunk.text);
}use pdfluent::{ExtractOptions, PdfDocument, Quality};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let doc = PdfDocument::open("report.pdf")?;
let markdown = doc.extract_markdown(&ExtractOptions::default())?;
let blocks = doc.extract_blocks(&ExtractOptions::default())?;
println!("{} blocks", blocks.len());
// balanced: needs the ort-layout/ort-tables features and installed models
let tables = doc.extract_markdown(&ExtractOptions::default().with_quality(Quality::Balanced))?;
println!("{markdown}\n{tables}");
Ok(())
}Pass quality="balanced" to extract_markdown. It needs installed models. Balanced (Preview) is Markdown only: extract_markdown reads it, extract_blocks refuses it. Structured extraction is Preview.
from pdfluent import Document
with Document("report.pdf") as doc:
md_tables = doc.extract_markdown(quality="balanced") # needs installed modelsPass { quality: "balanced" } to extractMarkdown. It needs installed models. Balanced (Preview) is Markdown only: extractMarkdown reads it, extractBlocks refuses it. Structured extraction is Preview.
const fs = require("node:fs");
const { PdfDocument, iterChunks } = require("@pdfluent/node");
const doc = PdfDocument.open(fs.readFileSync("report.pdf"));
const mdTables = doc.extractMarkdown({ quality: "balanced" });