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 NoneMany 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
| Field | Type | Description |
|---|---|---|
document_id | str | UUID generated for this parse result. |
run_id | str | UUID for the parse run, shared across retries of the same config. |
processed_at | str | None | ISO 8601 timestamp of when parsing completed. |
content_type | str | pdf, docx, pptx, or html. |
source_filename | str | None | Filename inferred from the source path (e.g. "report.pdf"). |
source_url | str | None | URL the document was fetched from, if applicable. |
file_size_bytes | int | None | Raw file size before parsing. |
is_password_protected | bool | Whether the document required a password. |
Page geometry & OCR
| Field | Type | Description |
|---|---|---|
page_count | int | Total 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_width | float | None | Page width in points. |
page_height | float | None | Page height in points. |
page_format | str | None | Detected page format, e.g. A4_PORTRAIT, US_LETTER_LANDSCAPE. |
has_mixed_page_sizes | bool | Whether the document contains pages of different sizes. |
has_ocr | bool | Whether OCR was applied during extraction. |
needs_ocr | bool | Whether the document appeared to need OCR but the OCR extra wasn't installed. |
is_scanned | bool | Whether the document was detected as a scanned image. |
Content statistics
| Field | Type | Description |
|---|---|---|
chars | int | None | Total extracted character count across all blocks. |
token_count | int | None | Total token count across all chunks. Exact when exact_tokens=True, otherwise a chars / 4 estimate. |
token_count_exact | bool | Whether 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).
| Field | Type | Description |
|---|---|---|
title | str | None | Resolved document title. |
author | list[str] | None | Resolved author list. |
language | str | None | Detected 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.
| Field | Type | Description |
|---|---|---|
created | str | None | ISO 8601 creation timestamp. |
modified | str | None | ISO 8601 last-modified timestamp. |
last_modified_by | str | None | Last editor's name. OOXML (DOCX/PPTX) only — always None for PDF and HTML. |
generator | str | None | Normalised 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
| Field | Type | Description |
|---|---|---|
processing_time | float | None | Wall-clock time in seconds for the full parse. |
extra | dict | Additional 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)