Page rendering in the in-house core
2026-11-18T13:26:35.317Z
Page rendering in the in-house core
PdfCore.renderPages(pdf, { pageIndexes, scale }) renders pages into compact display lists (a new pdf_core_render wasm export), and the new browser module @signature-kit/pdf-core/canvas paints them with Canvas 2D: renderDisplayListImage returns a PNG Blob per page (JPEG or WebP on request, oversized pages clamped to the canvas limits), paintDisplayList returns an Effect that draws into any 2D context and fails with a typed error on malformed display lists, and prepareDisplayListImages decodes the page images into a scoped map whose bitmaps are closed with the scope. The renderer covers paths, clipping, line styles, every PDF colour space (tint transforms included), Form XObjects, raster images (Rust-decoded samples with soft masks, mattes and colour keys, browser-decoded JPEG, Rust-decoded CCITT Group 3/4), axial and radial shadings, shading patterns, embedded TrueType, CFF, OpenType and Type 1 glyph outlines, Type 3 fonts, standard-font text runs, and annotation appearance streams. Optional content (OFF groups, OCMDs, BDC /OC, XObject and annotation /OC) is honoured, /Interpolate decides image smoothing so upscaled 1-bit images stay crisp, and clip render modes with standard fonts clip to glyph boxes. JPX and JBIG2 images draw a grey placeholder; mesh shadings, tiling patterns and soft masks are approximated. Glyph outlines, Type 3 glyphs and Form XObjects run under per-glyph and per-page work budgets, and decoded forms, Type 3 glyph programs and colour spaces are cached per document. Large images are downsampled to the render scale inside the core. New error code pdfCore.PAINT_FAILED (en-US/pt-BR messages included).
LiteParse removed
@signature-kit/pdf/liteparse-browser is replaced by @signature-kit/pdf/render-browser. renderPdfPagesBrowser(pdf, { pageIndexes?, scale? }) now requires the PdfPageRenderer service instead of LiteParseWorkerFactory: pdfPageRendererWorkerLayer({ timeoutMillis? }, create?) renders in a dedicated Web Worker with a per-request time limit (default 30 s) that terminates and replaces a stuck worker and fails with the new pdf.RENDER_TIMEOUT code, and pdfPageRendererLayer renders on the current thread from PdfCore. It renders through the in-house core and returns { pageIndex, width, height, image } with a PNG Blob instead of { pageNum, imageBytes }. liteParseWorkerBrowserLayer, LiteParseWorkerFactory and the LiteParse worker protocol are gone (PdfRenderRequests and pdfPageRendererHandlersLayer serve the new worker), and @llamaindex/liteparse-wasm is no longer a dependency. PdfHandwriting and pdfHandwritingBrowserLayer move to the same subpath. Render failures use the new pdf.page.render operation.