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 its own pure-Rust renderer (crate::render, tiny-skia) — close to, not identical with, that canvas (mean |Δ| ≈ 1/255 over the corpus), and heron’s borderline labels follow the pixels. This module lets the pipeline consume docling’s raster itself: 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, and Doc::render hands back the RGBA canvas docling’s get_page_image(scale) would. Since phase 5 of “Retiring pdfium” it is a development oracle: the conformance scripts ask for it by name, the default pipeline never loads it.

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 the Rust renderer.

  • DOCLING_RS_RENDERER — auto (default: the pure-Rust renderer, crate::render; the shim is never opened), docling-parse (the shim — what the conformance scripts run, because the baselines in tests/snapshots and docs/PDF_CONFORMANCE.md are its renders; a missing library warns once and falls back to the Rust renderer), rust (the default, spelled out) or pdfium (the library’s render, docling’s pypdfium2 chain — only in a build with docling-pdf’s pdfium feature, otherwise a one-time warning and the Rust renderer).
  • DOCLING_PARSE_RENDER_LIB — the shim library (a file, or the directory holding libdparse_render.so/.dylib); default .docling-parse/lib resolved like .models ([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", "rust" 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 DOCLING_RS_RENDERER=docling-parse asks for it and the shim loads; None otherwise — under auto the shim is never opened (the Rust renderer is the default), and an unavailable library under docling-parse warns once and falls back to the Rust renderer (degradation over failure).
requested
Is the docling-parse renderer explicitly requested?