Skip to content

Real-world PDFs

Scanned documents

When a PDF has no text layer, nirmala renders the first vision_pages (default 5) pages to JPEG (longest side 1568 px) and sends them to the vision client. Use a separate client or model with Extractor(vision_llm=..., vision_model=...), or turn this off with vision=False.

Encrypted PDFs

Extractor(passwords=["known", "candidates"])
Extractor(passwords=lambda doc: my_db.passwords(doc.metadata["customer_id"]))
Extractor(passwords=MyVault())          # any object with passwords_for(document)

Document(content, name, metadata) carries whatever your provider needs. If no candidate opens the file, PasswordRequired is raised with the number of candidates tried.

Several attachments

result = Extractor().extract_best([a, b, c], Policy, target="the insurance policy schedule")

Byte-identical files are dropped first. With more than one left, the model sees each file's first page (or its image, for scans) and is asked which one is the target. An UNCERTAIN answer raises ExtractionError instead of guessing.

Page budget

Only the first max_pages (6) text pages and max_chars (30,000) characters are sent. A field's hint= regex pulls in the first later page that matches when none of the kept pages do (up to extra_pages, default 2). That catches premium tables or totals printed on page 9.