Home

DocumentMetadata

Document-level metadata extracted during parsing. Available as result.metadata on every ParseResult.

result = docslicer.parse_document("report.pdf")
 
print(result.metadata.title)
print(result.metadata.page_count)
print(result.metadata.generator)   # "microsoft", "adobe", … or None

Many fields are conditional. Detection-dependent fields (title, author, language, page_width, file_size_bytes, …) are only present when DocSlicer could resolve them, and are omitted from to_dict() output when unset. Always guard for None when reading them.


Identifiers

FieldTypeDescription
document_idstrUUID generated for this parse result.
run_idstrUUID for the parse run, shared across retries of the same config.
processed_atstr | NoneISO 8601 timestamp of when parsing completed.
content_typestrpdf, docx, pptx, or html.
source_filenamestr | NoneFilename inferred from the source path (e.g. "report.pdf").
source_urlstr | NoneURL the document was fetched from, if applicable.
file_size_bytesint | NoneRaw file size before parsing.
is_password_protectedboolWhether the document required a password.

Page geometry & OCR

FieldTypeDescription
page_countintTotal page count. Falls back to 0 for formats that don't paginate or when the count can't be determined — always present in to_dict().
page_widthfloat | NonePage width in points.
page_heightfloat | NonePage height in points.
page_formatstr | NoneDetected page format, e.g. A4_PORTRAIT, US_LETTER_LANDSCAPE.
has_mixed_page_sizesboolWhether the document contains pages of different sizes.
has_ocrboolWhether OCR was applied during extraction.
needs_ocrboolWhether the document appeared to need OCR but the OCR extra wasn't installed.
is_scannedboolWhether the document was detected as a scanned image.

Content statistics

FieldTypeDescription
charsint | NoneTotal extracted character count across all blocks.
token_countint | NoneTotal token count across all chunks. Exact when exact_tokens=True, otherwise a chars / 4 estimate.
token_count_exactboolWhether token_count was computed with tiktoken or estimated.

Resolved metadata

These three are resolved fields: DocSlicer reads each from the document's embedded metadata and from the extracted text, then picks the better candidate (native wins, with a gate that rejects junk authors written by export tools).

FieldTypeDescription
titlestr | NoneResolved document title.
authorlist[str] | NoneResolved author list.
languagestr | NoneDetected language code (e.g. en, de, fr).

The per-channel intermediates behind that resolution (title_meta, title_text, author_meta, author_text, language_meta, language_text) exist on the dataclass but are pipeline internals — they are excluded from to_dict() and are not part of the public API.


Native metadata

Passed straight through from the document's own metadata, with no text-channel fallback. Present only when the format carries them and the document actually set them.

FieldTypeDescription
createdstr | NoneISO 8601 creation timestamp.
modifiedstr | NoneISO 8601 last-modified timestamp.
last_modified_bystr | NoneLast editor's name. OOXML (DOCX/PPTX) only — always None for PDF and HTML.
generatorstr | NoneNormalised vendor label for the authoring tool, shared across formats: microsoft, adobe, apple, libreoffice, google-docs, workiva, ghostscript, aspose, antenna-house, pdflib, reportlab, arbortext, or latex. None when nothing matches.

The raw strings behind generator differ per format — PDF classifies from /Creator plus /Producer, OOXML from docProps/app.xml — but the label you get is the same taxonomy either way. Authoring apps outrank PDF engines, so a file made by "Acrobat PDFMaker for Word" reports microsoft, not adobe.


Timing & extras

FieldTypeDescription
processing_timefloat | NoneWall-clock time in seconds for the full parse.
extradictAdditional metadata fields. Serialised only when non-empty.

Methods

to_dict()

Serialise to a plain dict. Pipeline intermediates are excluded, and conditional fields that are unset are omitted — so the key set varies per document.

Always present: document_id, run_id, processed_at, content_type, is_password_protected, page_count, has_mixed_page_sizes, has_ocr, needs_ocr, is_scanned. Everything else appears only when set. token_count_exact is a special case: it's emitted only alongside token_count, never on its own.

meta = result.metadata.to_dict()

DocumentMetadata.from_dict(d)

Reconstruct from a dict produced by to_dict().

from docslicer import DocumentMetadata
 
meta = DocumentMetadata.from_dict(d)