docling-project/docling-parse

Simple package to extract text with coordinates from programmatic PDFs

Docling Parse – Fast, configurable PDF extraction

What it is – A Python package (with a C++ core) that parses PDF files and returns structured text, word‑ and line‑level cells, vector shapes and bitmap images together with their coordinates. It is the low‑level engine used by the broader Docling PDF‑to‑structured‑data pipeline.

Why it matters – Modern LLM‑based workflows often need clean, position‑aware text and embedded graphics from PDFs (research papers, contracts, manuals, etc.). Docling Parse provides a high‑performance, thread‑safe way to obtain that data, letting downstream AI models work with exact layout information rather than raw strings.

Key features

  • Two‑stage configurationDecodeConfig (how pages are decoded) is fixed at open time; ContentConfig (what to compute/materialize) can be changed per page, enabling cheap initial loads and richer re‑parsing on demand.
  • Granular output levels – Choose to skip, compute, or materialize characters, words, lines, vector shapes, and bitmap images.
  • Sequential and multi‑threaded parsersDoclingPdfParser for single‑threaded use; DoclingThreadedPdfParser for parallel processing with back‑pressure control.
  • C++ core via pybind11 – Fast parsing and rendering; exposed as a pure‑Python API.
  • Rendering support – Render pages to images (via Blend2D/FreeType) with reproducible font fallback via environment variables.
  • CLI tooldocling-parse for quick command‑line extraction.
  • Benchmarks – Included scripts and reports comparing speed/quality against other PDF libraries.

Typical workflow

from docling_parse.pdf_parser import (
    DoclingPdfParser, DecodeConfig, ContentConfig, ContentLevel
)

parser = DoclingPdfParser(loglevel="fatal")
pdf = parser.load(
    path_or_stream="mydoc.pdf",
    decode_config=DecodeConfig(do_sanitization=True, keep_glyphs=False),
    content_config=ContentConfig(
        char_cells_content_level=ContentLevel.SKIP,
        word_cells_content_level=ContentLevel.COMPUTE_AND_MATERIALIZE,
        line_cells_content_level=ContentLevel.COMPUTE_AND_MATERIALIZE,
    ),
)

for page_no, page in pdf.iterate_pages():
    for word in page.iterate_cells(unit_type=TextCellUnit.WORD):
        print(page_no, word.rect, word.text)
    # optional image rendering
    img = page.render_as_image(cell_unit=TextCellUnit.WORD)
    img.show()

If richer data is needed later, call pdf.get_page(page_no, content_config=…) and the library will re‑decode that page automatically.

Installation

pip install docling-parse   # pulls the pre‑built wheels (C++ binary)

For development you can build the C++ part with CMake or use the uv toolchain as described in the README.

When to use it

  • Preparing PDFs for LLM ingestion where layout matters (tables, multi‑column text, figures).
  • Extracting images or vector graphics for downstream vision models.
  • High‑throughput batch processing of large document collections (thanks to the threaded parser).
  • Situations where you need deterministic rendering across machines – set the DOCLING_PARSE_*_FALLBACK_FONT env vars.

Links


Docling Parse is an MIT‑licensed, IBM‑originated open‑source library focused on PDF parsing rather than model training or inference, but it plays a crucial role in AI pipelines that need structured document data.

Related

  • Project
  • Project
  • Project
  • Project
  • Project