pdf_split
Split a PDF into individual pages or page ranges, saving each as a separate PDF file.
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).
- output_dirstringrequired
- Directory for output files; supports
${ctx.key}interpolation. - 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. - output_keystringdefault "pdf_split"
- Context key prefix for output values.
Providing both
pathandsource_keyis an error.
Context Output
<output_key>_files(defaultpdf_split_files) — array of file paths for the split PDF pages.<output_key>_page_count(defaultpdf_split_page_count) — number of pages extracted.<output_key>_success(defaultpdf_split_success) —trueon success.
Example
local flow = Flow.new("split_pdf")
flow:step("split", nodes.pdf_split({
path = "/data/document.pdf",
output_dir = "/data/pages",
pages = "1-3,5"
}))
flow:step("done", nodes.log({
message = "Split into ${ctx.pdf_split_page_count} files"
})):depends_on("split")
return flow