Skip to content

LearnIngest & extract

Rasterization

Page rendering

Rendering a page's vector drawing instructions into a grid of pixels, so OCR, vision models and previews can work from an image of the page.

In DocSlurpGlossary entry

On this page

Rasterization renders a page into pixels. A PDF page is a list of drawing instructions: paint these glyphs here, fill this path, place this image. A rasterizer such as poppler’s pdftoppm executes those instructions onto a grid of pixels at a chosen resolution, producing a PNG of the page.

Pipelines rasterize for three reasons:

  • OCR needs an image to read when a page has no trustworthy text.
  • Vision-language models take page images as input.
  • Previews and citations show the reader the actual page, so a cited passage can be checked against what was printed.

The resolution is set in DPI. A US Letter page (8.5 × 11 inches) at 150 DPI is 1,275 × 1,650 pixels; at 300 DPI it is 2,550 × 3,300, four times as many pixels to render, store and send to a model.

The point of rasterizing is that pixels don’t lie. A PDF text layer can be scrambled, unmapped or missing, but the rendered page shows exactly what a person sees.

The gotcha: a rasterizer executes untrusted instructions. A hostile PDF can declare a page 200 inches wide and ask for an enormous bitmap, or exploit a bug in the renderer. Cap the pixel count before rendering, and run the renderer in a sandbox, never inside a process that holds secrets.

In DocSlurp

In DocSlurp

Selected pages render with poppler's pdftoppm in the parser sandbox (the native engine is an opt-in alternative) and are cached per DPI (core/worker/src/pipeline/pdf-asset-cache.ts). The render-images stage chooses which pages need pixels for previews, OCR and vision (core/worker/src/stages/render-images.ts).

Sources

Jump to