Skip to main content

render_pdf_pages

Function render_pdf_pages 

Source
pub fn render_pdf_pages(
    bytes: &[u8],
    password: Option<&str>,
    range: Option<(usize, usize)>,
    scale: f32,
) -> Result<Vec<RenderedPage>, PdfError>
Expand description

Rasterize a PDF’s pages to PNG (#243) — the lean path behind serve’s to=images: pdfium render only, no text extraction, no models, and only one page bitmap resident at a time (each is PNG-encoded and dropped before the next renders). scale is pixels per PDF point — 2.0 matches the pipeline’s RENDER_SCALE (144 dpi). Unlike the pipeline’s render there is no 1.5× supersample + downsample pass: that dance exists only because TableFormer is pixel-pinned to docling’s bitmaps, and nothing downstream of this output is — a single render is nearly twice as fast.

range is a 1-based inclusive page window (issue #80’s pages semantics: the end clamps to the document, a start past the end errors).

pdfium is not thread-safe — callers must serialize this against any other pdfium use (docling-serve holds its pipeline mutex around this call for exactly that reason).