Skip to main content

Module dparse_render

Module dparse_render 

Source
Expand description

Opt-in page-image plugin: docling-parse’s Blend2D renderer, loaded at runtime (#478).

docling 2.123+ renders every page image its model stages consume — the scale-1.0 layout input, the scale-2.0 TableFormer input, the OCR and enrichment crops — with docling-parse’s own renderer (FreeType glyph outlines filled by Blend2D), while this pipeline renders them with pdfium exactly like docling’s PyPdfiumDocumentBackend. The two rasters differ at every glyph edge (10 % of the corpus pixels by > 8/255), and heron’s borderline labels follow the pixels. This module lets the pipeline consume docling’s raster instead: a small C shim over renderer<BLEND2D> (crates/docling-pdf/ffi/docling-parse-render/dparse_render.cpp, built by scripts/install/build_docling_parse_render.sh) is dlopened the way pdfium is, and Doc::render hands back the RGBA canvas docling’s get_page_image(scale) would.

Selection is an environment knob, never a build feature: nothing links the C++ side, CI and wasm are untouched, and a missing library degrades to pdfium.

  • DOCLING_RS_RENDERER — auto (default: docling-parse when the shim library resolves, pdfium otherwise, silently — the baselines in tests/snapshots and docs/PDF_CONFORMANCE.md are docling-parse’s, so a checkout with the library converts like the baselines and one without still converts), docling-parse (required: a missing library warns once and falls back to pdfium) or pdfium (never load the plugin).
  • DOCLING_PARSE_RENDER_LIB — the shim library (a file, or the directory holding libdparse_render.so/.dylib); default .docling-parse/lib resolved like .pdfium/lib ([crate::resolve_asset]).
  • DOCLING_PARSE_RESOURCES — docling-parse’s pdf_resources directory (fallback fonts, encodings, cmaps); default <lib dir>/../pdf_resources, where the build script installs it.

The renderer is docling-parse’s, so its output is compared against the Python package’s PageParseResult.get_image(scale) byte for byte (scripts/conformance/dparse_render_check.py); everything downstream — the Pillow-exact 640 stretch, the TableFormer crop chain — is unchanged.

Structs§

Doc
A PDF opened by docling-parse; renders its pages on request.
Plugin
The loaded shim: the library plus its resolved entry points. One per process, behind plugin.

Enums§

Choice
What DOCLING_RS_RENDERER asks for.

Functions§

active_name
Which renderer produces the model inputs in this process: "docling-parse" or "pdfium" — for diagnostics (--version-style banners, serve health).
choice
The renderer DOCLING_RS_RENDERER selects; unset, empty or auto is Choice::Auto, an unknown value warns once and counts as auto.
plugin
The plugin when the shim loads and choice allows it; None otherwise. Under auto an unavailable library is a quiet (DOCLING_RS_DEBUG) note and the pipeline renders with pdfium; under docling-parse it warns once first (degradation over failure either way).
requested
Is the docling-parse renderer explicitly requested?