IronFlowDocs

pdf_thumbnail

Render a single PDF page to an image using the native pdfium library at runtime.

Parameters

pathstringone of path or source_key
File path to the PDF; supports ${ctx.key} interpolation.
source_keystringone of path or source_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, or jpg.
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 width and height are 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 path and source_key is an error. Requires the pdfium native library. Set PDFIUM_LIB_PATH, place libpdfium in the working directory, or install system-wide.

Context Output

  • <output_key> (default thumbnail) — 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 — always 1.

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, default 104857600.
  • IRONFLOW_MAX_PDF_RENDER_PIXELS — maximum pixels in the rendered thumbnail, default 25000000.
  • IRONFLOW_MAX_PDF_DPI — maximum accepted DPI, default 300.

IronFlow documentation

Find the next step

Type a keyword to search the documentation.

to move · Enter to open · Esc to close