Document Content Classification#
Document content classification in Docling operates on two orthogonal axes:
ContentLayer— assigns each element a functional layer (body, furniture, background, etc.) for selective filtering during export and iteration.DocItemLabel— assigns each element a structural type (text, table, picture, page header, etc.) used by downstream models and renderers.
These two attributes live on every NodeItem in the document tree. The classification is assigned during PDF pipeline assembly (primarily by the ReadingOrderModel) and by format-specific backends (Word, HTML, PPTX). All export and iteration methods accept included_content_layers to filter which content surfaces in the output.
ContentLayer Enum#
Defined in docling_core/types/doc/document.py:
| Value | Meaning |
|---|---|
BODY | Main content of the document |
FURNITURE | Page headers and footers |
BACKGROUND | Watermarks and background elements |
INVISIBLE | Hidden or invisible text |
NOTES | Author/speaker notes, corrections |
DEFAULT_CONTENT_LAYERS = {ContentLayer.BODY} is the fallback used when callers pass included_content_layers=None. This means CLI and API exports silently drop furniture, watermarks, and notes unless the caller explicitly opts in.
Every NodeItem defaults to ContentLayer.BODY at construction time.
DocItemLabel Enum#
Defined in docling_core/types/doc/labels.py. Selected values relevant to layer classification:
| Label | Notes |
|---|---|
PAGE_HEADER | Detected page header → mapped to FURNITURE layer |
PAGE_FOOTER | Detected page footer → mapped to FURNITURE layer |
TITLE, SECTION_HEADER, TEXT, PARAGRAPH | Mapped to BODY |
TABLE, PICTURE, FORMULA, CODE | Mapped to BODY |
FOOTNOTE, CAPTION | Mapped to BODY |
HANDWRITTEN_TEXT, CHECKBOX_SELECTED/UNSELECTED | Mapped to BODY |
There is no dedicated WATERMARK DocItemLabel; watermark content is classified at the ContentLayer level (BACKGROUND) rather than as a distinct structural label.
For fine-grained picture classification, see PictureClassificationLabel, which includes chart types, photographs, barcodes, and chemistry structures — used by the DocumentPictureClassifier model.
Layer Assignment#
PDF Pipeline (Reading Order Model)#
The ReadingOrderModel is the primary site for layer assignment during PDF processing. It runs as part of StandardPdfPipeline._assemble_document(). Two methods apply layer logic:
_add_child_elements: When building child items in composite elements, items labeledPAGE_HEADERorPAGE_FOOTERreceiveContentLayer.FURNITURE; all others receiveContentLayer.BODY._handle_text_element: Same logic applied when handling top-level text elements from the layout model output.
Format-Specific Backends#
- Word/DOCX: Headers and footers discovered during
_add_header_footer()are taggedContentLayer.FURNITUREdirectly byMsWordDocumentBackend. - HTML: When
infer_furniture=True, content before the first heading is taggedContentLayer.FURNITURE; subsequent content isBODY. - PPTX: Supports
included_content_layersat export time but does not auto-assign non-BODY layers.
The BACKGROUND and INVISIBLE layers are defined in the enum but are not yet assigned by any built-in model or backend — watermark detection is not a current pipeline stage. They are reserved for future use or custom assignment.
Filtering by Content Layer#
All traversal and export methods accept included_content_layers: Optional[set[ContentLayer]]:
DoclingDocument.iterate_items(): Yields only nodes whosecontent_layeris in the provided set. Falls back toDEFAULT_CONTENT_LAYERS(BODY only) whenNone.export_to_markdown(),export_to_html(),export_to_text(): All thread the same parameter through toiterate_items().
To include headers/footers in Markdown output:
from docling_core.types.doc import ContentLayer
doc.export_to_markdown(
included_content_layers={ContentLayer.BODY, ContentLayer.FURNITURE}
)
The VLM pipeline passes included_content_layers=set(ContentLayer) — all layers — when assembling the intermediate per-page document, ensuring no content is dropped before final post-processing.
Default behavior summary:
| Context | Layers included |
|---|---|
| CLI / Serve API export | BODY only |
| Python SDK default | BODY only |
| VLM pipeline internal assembly | All layers |
Custom via included_content_layers= | Caller's choice |
Key Source References#
| Artifact | Location |
|---|---|
ContentLayer enum + DEFAULT_CONTENT_LAYERS | docling_core/types/doc/document.py |
NodeItem.content_layer field | docling_core/types/doc/document.py |
_iterate_items_with_stack() (filtering logic) | docling_core/types/doc/document.py |
DocItemLabel enum | docling_core/types/doc/labels.py |
PictureClassificationLabel enum | docling_core/types/doc/labels.py |
| Layer assignment in ReadingOrderModel | docling/models/stages/reading_order/readingorder_model.py |