pdf::classify
Classify a PDF as text-based, scanned, image-based or mixed, and report which pages need OCR and why. Samples content streams rather than extracting text, so it answers in tens of milliseconds. Call this before any other pdf function.
- bytes_base64string
Base64-encoded PDF bytes, for a document with no path. Mutually exclusive with `path`.
- fs_scopeany of
The filesystem jail this call runs under. Stamped by the harness on an agent's call; absent on an operator or console call, which is already user-initiated and not subject to the agent's scope.
any of (2)variant 1- grantsstring[]
Additional directories or files explicitly granted to this session.
- rootstringrequired
The session's working directory.
variant 2valuenull - passwordstring
Password for an encrypted document. Never logged or echoed back.
- pathstring
Filesystem path to the PDF. Mutually exclusive with `bytes_base64`.
- sample_pagesinteger· uintmin 0
Pages sampled for the verdict, overriding the configured default. `0` scans every page, which is slower but settles a borderline mixed document.
- confidencenumber· floatrequired
How much to trust the verdict, from 0.0 to 1.0.
- document_typeall ofrequired
The document-level verdict.
all of (1)variant 1one of (4)variant 1valuestringenum: text_basedvariant 2valuestringenum: scannedvariant 3valuestringenum: image_basedvariant 4valuestringenum: mixed - elapsed_msinteger· uint64requiredmin 0
Wall-clock time for the classification.
- has_encoding_issuesboolean
`true` when font encodings decoded badly. Only known on the encrypted path, which extracts far enough to notice; absent otherwise, where `suspected_garbled_text` in `ocr_reasons` carries the same signal.
- ocr_reasonsobject[]required
Per-page explanation for `pages_needing_ocr`.
- pageinteger· uint32requiredmin 0
1-indexed page number.
- reasonsstring[]required
Machine-readable reasons: `scanned` (a raster page), `no_text` (nothing extractable and nothing to OCR), `vector_text` (characters drawn as outlines rather than text) or `suspected_garbled_text` (a text layer that decodes to nonsense).
- ocr_recommendedboolean
`true` when the images carry meaning the text layer does not, so OCR adds something even on a text-based document. Absent for an encrypted document, for the same reason as `pages_sampled`.
- page_countinteger· uint32requiredmin 0
Pages in the document.
- pages_needing_ocrinteger[]· uint32requiredmin 0
1-indexed pages that cannot be read without OCR. Empty for a clean text-based document.
- pages_sampledinteger· uint32min 0
Pages actually inspected. Lower than `page_count` when sampling, so a verdict from a sample can be told apart from one that read everything. Absent for an encrypted document, which takes a decryption path that does not report the counters.
- pages_with_textinteger· uint32min 0
Inspected pages that carry text operators. Absent for an encrypted document, for the same reason as `pages_sampled`.
- sourcestringrequired
Source label: the file name, or `<inline>` for an in-memory document.
- titlestring
Document title from the PDF metadata, when it has one.