Expand description
The pure-Rust page renderer — phase 3 of retiring pdfium
(docs/PDF_CONFORMANCE.md, “Retiring pdfium”): the raster of a page’s
vector content, text and images that the layout / TableFormer / OCR
stages consume — the default renderer since phase 5 (docling-parse’s
renderer plugin draws them only under DOCLING_RS_RENDERER=docling-parse).
It draws what docling-parse’s renderer<BLEND2D> draws, in its frame:
the page’s crop box on a ceil(width · scale) × ceil(height · scale)
white canvas (resolve_canvas_size), y down, the box mapped onto the
whole canvas, /Rotate applied to the finished pixels; content-stream
semantics as in content; fonts as in font; the anti-aliased
rasterizer, strokes, masks, gradients and image blits are tiny-skia’s.
It is not byte-identical to that renderer — Blend2D’s font engine,
rasterizer and JIT compositor round differently — and the docling-parse
shim stays the reference the PDF baselines are pinned to; this renderer
is measured against it (tests::against_the_docling_parse_shim).
Modules§
- color
- Colour spaces (ISO 32000-1, 8.6) → device RGB in
[0, 1]. - content
- The content-stream interpreter (ISO 32000-1, 8–9): graphics state, path construction and painting, clipping, text, XObjects, inline images, shadings and patterns, ExtGState, and the widget annotations’ appearance streams — drawn onto a tiny-skia canvas in device space.
- font
- PDF fonts for the renderer: a font dictionary becomes a
LoadedFontthat splits strings into codes, gives each code its advance and its glyph outline in text space, or — for Type 3 — its glyph procedure. - function
- PDF functions (ISO 32000-1, 7.10): sampled (type 0), exponential (2),
stitching (3) and PostScript calculator (4) — what shadings, Separation /
DeviceN tint transforms and
/Decode-less colour ramps evaluate. - geom
- Affine geometry for the renderer: PDF’s
[a b c d e f]matrices inf64, applied asx' = a·x + c·y + e,y' = b·x + d·y + f(ISO 32000-1, 8.3.4). - image
- Image XObjects and inline images → premultiplied RGBA pixmaps
(ISO 32000-1, 8.9): every bit depth, the colour spaces of
super::color,/Decoderanges, stencil masks painted in the fill colour,/SMasksoft masks, stencil and colour-key/Masks. The sample data comes through the raster’s filter chain, its libjpeg-exact JPEG decoder and its CCITT decoder; JPX and JBIG2 have no decoder here and come out as a mid-gray block (the picture the layout model should see is “a picture”). - objects
- Small lopdf helpers shared by the renderer’s modules.
- prepass
- A pre-pass over a content stream for the two constructs lopdf’s content lexer (0.44) does not hand over intact:
Structs§
- Renderer
- A document’s renderer: the per-document caches (fonts, CMYK table,
decoded image samples) that its page renders share. The pipeline renders
every page at two scales; hold one
Rendererper document across both.
Functions§
- pixels_
for_ extent - docling-parse’s
pixels_for_extent:ceil(extent − 1e-6). - render_
page - One-off
Renderer::render_scaled(no cache carried across pages). - render_
page_ sized - One-off
Renderer::render.