Version: 0.0.5 (stable)
agrag.loaders.docling.loader.DoclingPdfLoader
Bases: DoclingLoader
Reads PDF and image files with docling.
PDF needs the docling extra, which installs the layout and table models. The
loader runs OCR on a PDF only where the PDF has no text layer, except for a PDF
with at least 80% of pages lacking text, which gets full-page OCR. It reads
heading depth from the bookmarks of the PDF. A PDF with no bookmarks whose
headings carry dotted numbers gets its depth from the numbers.
Attributes:
- extensions – The PDF and image formats this loader reads.
- extra – The package extra that installs the models.
- extra_module – The model package that only the extra installs. The core docling package is present without the extra, so it cannot prove the extra is installed.
Functions:
- is_available – Return whether the package that the loader's extra installs is present.
- load – Yield one prose Document parsed by docling.
extensions
extensions = frozenset(_formats)
extra
extra = 'docling'
extra_module
extra_module = 'docling_ibm_models'
family
family = DocumentFamily.PROSE
is_available
is_available() -> bool
Return whether the package that the loader's extra installs is present.
A loader with no extra is always available. The check looks the module up without importing it, so an installed package that fails to import still counts.
load
load(source:SourceRef, stream:BinaryIO, opts:ReadOptions, *, start_at:int = 0) -> Iterator[Document]
Yield one prose Document parsed by docling.
Parameters:
- source (
SourceRef) – The source to read. - stream (
BinaryIO) – The open binary stream for the source. - opts (
ReadOptions) – The read options. - start_at (
int) – Ignored by prose loaders.
Yields:
Document– One Document. Whenopts.store_textis on, its text is the doclingDocument– Markdown export and its sections hold the content; with the flag offDocument– both are empty. Its title is the first heading, or the file name whenDocument– the source has no heading.
Raises:
DocumentTooLargeError– The source is larger than the configured byte limit.MissingExtraError–DoclingPdfLoaderonly. A package that docling needs is not installed, and the error names thedoclingextra. It is anUnsupportedFormatError, so SKIP and QUARANTINE treat it like an unsupported format.ImportError–DoclingLoaderonly. A package that docling needs is not installed. This is an install problem, not a problem with the source, so the walker policies do not catch it.DocumentConversionError– Docling or its export failed on the source, for any other reason. Walker policies such as SKIP and QUARANTINE catch this error.ValueError–opts.max_document_bytesis not a positive integer.
mime_types
mime_types: frozenset[str] = frozenset()