pdf_to_image
Render PDF pages to images 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).
- pagesstringdefault "all"
- Page specification:
"all", a single page"3", a range"1-5", or a combination"1-3,7,9-11". Pages are 1-based. - formatstringdefault "png"
- Image format:
"png","jpeg", or"jpg". - dpinumberdefault 150.0
- Resolution in dots per inch for rendering.
- output_keystringdefault "images"
- Context key where the array of rendered image objects is stored.
Providing both
pathandsource_keyis an error. Requires thepdfiumnative library. SetPDFIUM_LIB_PATHenv var, placelibpdfiumin the working directory, or install it system-wide.
Context Output
<output_key>(defaultimages) — an array of objects, one per rendered page, each containing:page— 1-based page number.width— rendered image width in pixels.height— rendered image height in pixels.format— the image format ("png","jpeg", or"jpg").image_base64— base64-encoded image data.
page_count— total number of pages in the PDF document.
Example
local flow = Flow.new("render_pdf_pages")
flow:step("render", nodes.pdf_to_image({
path = "/data/document.pdf",
pages = "1-3",
format = "png",
dpi = 200,
output_key = "images"
}))
flow:step("done", nodes.log({
message = "Rendered ${ctx.page_count} total pages, got ${ctx.images} image(s)"
})):depends_on("render")
return flow
Limits
pdf_to_image reads the PDF into memory and stores rendered images as base64 in workflow context. The following process limits are enforced:
IRONFLOW_MAX_PDF_BYTES— maximum PDF file size, default104857600.IRONFLOW_MAX_PDF_RENDER_PAGES— maximum pages rendered by one node call, default25.IRONFLOW_MAX_PDF_RENDER_PIXELS— maximum pixels per rendered page, default25000000.IRONFLOW_MAX_PDF_DPI— maximum accepted DPI, default300.