pdf_thumbnail
Render a single PDF page to an image using the native pdfium library at runtime.
Parameters
- pathstringone of
pathorsource_key - File path to the PDF; supports
${ctx.key}interpolation. - source_keystringone of
pathorsource_key - Context key whose value is the file path (must be a string).
- pagenumberdefault 1
- 1-based page number to render.
- formatstringdefault png
- Image format:
png,jpeg, orjpg. - widthnumber
- Exact thumbnail width in pixels. If set, height is auto-scaled.
- heightnumber
- Exact thumbnail height in pixels. If set, width is auto-scaled.
- sizenumberdefault 256
- Maximum side length when
widthandheightare not both provided. - dpinumberdefault 150
- Resolution in dots per inch for rendering before scaling.
- output_keystringdefault "thumbnail"
- Context key to store thumbnail object.
Providing both
pathandsource_keyis an error. Requires thepdfiumnative library. SetPDFIUM_LIB_PATH, placelibpdfiumin the working directory, or install system-wide.
Context Output
<output_key>(defaultthumbnail) — an object containing:page— 1-based page number.width— rendered thumbnail width in pixels.height— rendered thumbnail height in pixels.format— the image format ("png","jpeg", or"jpg").image_base64— base64-encoded image bytes.
<output_key>_count— always1.
Example
local flow = Flow.new("pdf_thumbnail_demo")
flow:step("thumb", nodes.pdf_thumbnail({
path = "examples/fixtures/ironflow-sample.pdf",
page = 1,
format = "png",
size = 320,
dpi = 150,
output_key = "preview"
}))
flow:step("show", nodes.log({
message = "Generated preview ${ctx.preview.width}x${ctx.preview.height}"
})):depends_on("thumb")
return flow
Limits
pdf_thumbnail shares the PDF rendering safeguards used by pdf_to_image:
IRONFLOW_MAX_PDF_BYTES— maximum PDF file size, default104857600.IRONFLOW_MAX_PDF_RENDER_PIXELS— maximum pixels in the rendered thumbnail, default25000000.IRONFLOW_MAX_PDF_DPI— maximum accepted DPI, default300.