@nextgensoftwares/folio-render-node
Server-side page images and flattened PDFs with the watermark baked into the pixels, for hosts that serve protected pages instead of document data. Node ≥ 20; uses @napi-rs/canvas (MIT, prebuilt) through @nextgensoftwares/folio-render-canvas. Guide: Reader & protection.
ts
const page = await renderPageImage(layout, 0, { fonts, pageLayers, painters, variables: { user }, dpi: 144, format: 'webp' });
res.type('image/webp').send(page.data);| Export | Description |
|---|---|
renderPageImage(layout, index, options?) | one page (0-based) → PageImage ({ data, width, height, format, index }); throws RangeError for a missing page |
renderPageImages(layout, pages, options?) | several pages (1-based PageSelection) |
nodeRasterizer(options?) | a PageRasterizer for exportFlattenedPdf |
exportFlattenedPdfNode(layout, options?) | flattened PDF (image-only pages) with pages, dpi, permissions, render options |
type NodeRenderOptions | CanvasRenderOptions plus fonts, dpi (default 144) or scale, format ('png' | 'webp' | 'jpeg'), quality, images |
type PageImage, type PageImageFormat | render result and format |
registerFonts(faces), type NodeFontFace | registers font files ({ family, data }) once |
nodeImageLoader(source?), type NodeImageSource | image loading; default accepts only data: URLs (no network from document content) |
Canvases are capped at 60 megapixels per page so a hostile page size can't exhaust memory. Register the same font files the layout was measured with (variable fonts work: the canvas picks the instance by weight).