Repository navigation
PDFluent SDK 1.5.0
Tag: v1.5.0 · Licence: AGPL-3.0 or the PDFluent Commercial Licence, at your option
PDFluent 1.5.0 adds new ways to create documents, read page images and codes, and move extraction results into data tools. It ships for Rust, Python, Node.js, WebAssembly, Java, .NET and C.
Licence
The licence does not change: PDFluent 1.5.0 is available under the GNU AGPLv3 or the PDFluent Commercial Licence, at your option, as 1.4.0 was. Every package declares both and carries the LICENSE and LICENSE-COMMERCIAL files. NOTICE and THIRD_PARTY_LICENSES.txt now also attribute Apache OpenDAL, Apache Arrow, Apache Parquet and the HTTP and TLS libraries that the Python wheel links.
New documents, page images, OCR, barcodes and zones
images_to_pdfbuilds a PDF from images, andcreate_blank_pdfbuilds one from blank pages.Document.rasterizerenders pages to images, andDocument.ocrwrites an OCR copy.Document.read_barcodesreads barcodes and QR codes.Document.read_mrzreads machine-readable zones on identity documents.
These are available in Rust, Python, Node.js, Java, .NET and through the C API. WebAssembly has imagesToPdf, createBlankPdf and readMrz. Barcode reading is the barcode feature of pdf-engine and pdfluent, written in Rust, and it is on in the Python, Node.js and C builds. A page too large to render is skipped without failing the others. read_barcodes_report (Python and Rust), readBarcodesReport (Node.js and Java), ReadBarcodesReport (.NET) and pdf_document_read_barcodes_report (C) return the skipped pages with their reasons next to the codes; read_barcodes returns the codes only.
Extraction results as data
pdfluent.columnar(Python) writes extraction results as JSONL, Apache Arrow record batches and Parquet, in one documented column schema. You can pass your own embeddings; the SDK does not compute them.pdfluent.storage(Python) reads documents from, and writes outputs to, Apache OpenDAL services by URI. The default wheel has the local file, in-memory and HTTP services and presigned GET and PUT. Cloud services need a wheel built with thestorage-servicesfeature. Credentials stay in memory and are removed from error messages.pdfluent-dltis a dlt resource that yields extraction rows. It needspdfluent>=1.5.0.- A Haystack converter is new. The LangChain and LlamaIndex loaders gain a
flatten_metadataoption. pdfluent-mcp0.3.0: the local server's tools are the hosted API's tools. The 0.2 tool names stay as deprecated aliases for one release.
Opt-in enrichment
Figure and table descriptions, and extraction to a JSON Schema, with your own model provider and key. They are in builds with the enrich feature only. The default Python wheel and Node.js addon do not have describe_elements and extract_to_schema, and the Python type stubs now say so: the two methods are on the stub-only class DocumentWithEnrich, which you opt into with typing.cast.
Extraction to a JSON Schema now refuses a schema that uses a keyword the validator cannot check, before the model is asked and before any provider tokens are spent. The refused keywords are pattern, format, $ref, oneOf, allOf, not, uniqueItems and similar (the full list is UNSUPPORTED in pdfluent-enrich). Previously such keywords were ignored, so an answer that broke them was returned as valid. Use type, enum, const, required, properties, additionalProperties, items, minItems/maxItems, minimum/maximum, minLength/maxLength and anyOf.
Network access
The SDK makes network requests only when you call a function that names a remote location (a pdfluent.storage URI or a presigned URL) or your own model provider (the enrich feature). Importing the package and processing local files opens no socket, and a test in CI checks this.
The default Python wheel now contains an HTTP and TLS client, because pdfluent.storage is part of it. The client is used only when you call a function with a remote location. TLS uses rustls with ring. Building the wheel from source needs Rust 1.91 or later.
Extraction
- Chart reading is opt-in: pass
charts=Trueto read the type, title and data labels of a drawn chart intoBlock.chart. The default is off. - Blocks read from a scanned page can be captions, footnotes and list runs, and keep page-break continuity.
- A table split by a page break stays one table when a footnote or a continued label sits between the parts.
- A line struck through by a drawn rule is written struck out.
- A loose line keeps the engine's heading when it is set large (rule R167).
BlockKind::Footnoteis a new variant.BlockKindis#[non_exhaustive], so a downstreammatchalready has a wildcard arm. The variant is declared afterFigure, so no discriminant of an earlier variant changes.
Python
Document gains split, watermark, replace_text, form data, XFA, PDF/A and PDF/UA methods, and Document.to_markdown as an alias of extract_markdown.
Compatibility preview
The PyMuPDF-compatible layer stays a preview. In Node.js it gains geometry operators on the geometry classes, page defaults, journal and drawing records, Document.formFieldCount, Page.getLinkRecords and Page.linkRecords. The module-level helpers (utilTransformPoint, utilUnionRect and the others) return the same geometry objects as in 1.4.0, and utilPointInQuad returns a boolean. Members that kept their 1.4.0 shape get an additive partner where the compatible API needs another one: Page.firstAnnot is the 1.4.0 record and Page.firstAnnotObject the live annotation; Page.mediaboxSize is the 1.4.0 [width, height] array and Page.mediaboxSizePoint a Point. The TypeScript interfaces PointLike, RectLike, IRectLike, MatrixLike and QuadLike are the 1.4.0 ones; parameters that also take tuples use the new PointOperand, RectOperand and sibling types.
PyMuPDF and MuPDF are trademarks of Artifex Software, Inc. PDFluent is an independent product of Innovation Trigger B.V. and is not affiliated with or endorsed by Artifex.
Fixes
- A document opened with a password and then saved no longer comes out as an empty PDF (#1231).
- A signed document saved with
to_bytes(),save()orwrite_to()keeps a valid signature (#1292). This includes a document signed withPdfDocument::signand then saved: the full rewrite used to move the signed byte range, andverify_signatures()on the saved file reportedbyte range exceeds PDF size. - Signing a document that is already signed keeps the earlier signatures valid (#1292).
PdfDocument::sign,PdfDocument::sign_timestampedandpdfluent_sign::sign_pdfnow append the new signature as an incremental update instead of rewriting the file, which used to break every signature already in it. mergekeeps the form fields and inherited page attributes of its inputs.pdfluent-dltrequiredpdfluent>=1.4.0, butpdfluent.columnarfirst exists in 1.5.0. It now requirespdfluent>=1.5.0.- The Python stub file
_native.pyihad a syntax error in one signature; it parses now. - In Node.js, a compatible-API object whose prototype was changed to another class is refused with a
TypeErrorinstead of being read as that class. - Integer options of the C API and WebAssembly that do not fit their type (for example a page count or a resolution above 2^32) are refused instead of being truncated.
- The form-script sandbox runs on wasmi 2.0.1. wasmi 2.0.0 was withdrawn from crates.io, so a fresh
cargobuild that resolvedxfa-js-sandboxed1.2.2 failed; 2.0.1 also fixes stack overflows on some modules and a divide-by-zero on malformed input.
Upgrading from 1.4
extract_blocks,extract_elementsand the APIs and bindings built on them now recognize whole scanned pages atQuality::Autowith the unset defaultOcrMode::Unset(#1147).extract_markdownhas done this since 1.4.0. A scanned page comes back as text blocks instead of one empty figure. The cost: every such call runs an extra survey pass over the pages in the window, and when atesseractbinary is onPATH, each page the survey calls a whole scan is recognized with one Tesseract run. Born-digital pages are not sent to Tesseract. UseQuality::Fastfor no OCR at all.to_bytes(),save()andwrite_to()write a document that carries a digital signature as an incremental update over the bytes it was loaded from, the wayto_incremental_bytes()does, instead of rewriting the whole file (#1292). The output of these calls changes only for signed documents: it is longer, keeps the earlier revision, and every signature in it still verifies. Encrypted and redacted documents are still rewritten in full. To strip the earlier revision from a signed document, which breaks its signatures, useto_bytes_plain().- An
OcrMode::Neveris now honoured at every quality tier, however it is set:options.ocr = OcrMode::Never,ExtractOptions::with_ocr(OcrMode::Never), Pythonocr="never"and Nodeocr: "never"start no survey pass and no OCR engine, also atQuality::Auto. Options that leaveocrunset read as before.OcrModeis#[non_exhaustive], so the newOcrMode::Unsetvariant, the new default ofExtractOptions::ocr, is not a semver break; code that compared the default toOcrMode::Nevershould compare toOcrMode::Unset, or callOcrMode::is_off()for "no OCR asked for".
Component crates
pdf-engine, pdf-render, pdf-annot, pdf-compliance, pdfluent-forms and pdfluent-sign keep the major versions they moved to in 1.4.0.
Patch releases in 1.5.0: xfa-js-sandboxed 1.2.3, xfa-layout-engine 2.0.2, pdf-xfa 2.0.2, pdfluent-forms 2.0.1, pdf-engine 2.0.1, docx-extract 1.1.1, formcalc-interpreter 1.1.3, xfa-dom-resolver 1.1.3, pdf-compliance 2.0.1, pdf-render 2.0.1, pdf-annot 2.0.1 and pdfluent-sign 2.0.1.
Install and upgrade
cargo add pdfluent@1.5.0
pip install pdfluent==1.5.0
npm install @pdfluent/node
npm install @pdfluent/sdk-wasm
dotnet add package PDFluent --version 1.5.0
Java: com.pdfluent:pdfluent 1.5.0 follows on the PDFluent Maven repository, https://maven.pdfluent.com, once the release is signed.
Upgrading from 1.4:
pdfluent-dltusers: upgradepdfluentto 1.5.0 first.- Code that calls
describe_elementsorextract_to_schemaneeds a build with theenrichfeature, as before.
Questions and problems: https://github.com/pdfluent/pdfluent-sdk/discussions · Full changelog: https://pdfluent.com/changelog/