All templates
PDFIntermediate
Split PDF by Specified Page
Robomotion•Updated 9 months ago

Overview
Splits a PDF into two files at a user-specified page number. Ideal when you know exactly where a document should be divided.
Split PDF by Specified Page
Splitting PDF files into two uneven parts is a typical request, as they often contain two different types of information, such as an order summary and a receipt. Robomotion can automate these scenarios, allowing users to create flows that split PDF files at any possible point.
What Split PDF by Specified Page can do
Core.Flow.SubFlowDownload Fixturespreps sample data, thenCore.Programming.Functionbuildsmsg.default_pdf = global.get('$Home$') + '/templates/pdf-automation/split-pdf-by-specified-page/fixtures/sample.pdf'.- Input Dialog titled
Split a PDF into two parts, messageSelect a PDF file to split:, defaultmsg.default_pdf->msg.pdf_path. - Input Dialog titled
Split a PDF into two parts, messageSplit at page number:, default3->msg.split_at_text. - Validate (
Core.Programming.Function,outputs: 2) — requires a.pdfpath and integern >= 1; extractsmsg.directory,msg.stem,msg.split_at_page, and derivesmsg.pages_dir = <dir>/_pages_<stamp>andmsg.split_output_dir = <dir>/split_parts_<stamp>; failure goes toCore.Flow.Stop. Core.FileSystem.Create(directory,continueOnError) onmsg.pages_dir, thenRobomotion.PDFBox.Split(optPerPage: 1, prefixp) bursts the source intomsg.pages_dir.Core.FileSystem.List(optAbsolutePath: true,optSort: 'ascend') ->msg.page_files; plan halves (Core.Programming.Function,outputs: 2) requires>=2pages and1 <= n < count, slices intomsg.first_paths/msg.second_paths, and computesmsg.first_out = <split_dir>\<stem>-1.pdfandmsg.second_out = <split_dir>\<stem>-2.pdf.Core.FileSystem.Createonmsg.split_output_dir, then twoRobomotion.PDFBox.Mergecalls writemsg.first_outandmsg.second_out.Core.FileSystem.Deletecleansmsg.pages_dir, then a Function buildsmsg.dialog_textandCore.Dialog.MessageBoxtitledFlow has been completed!shows the output directory.
Behind the scenes
- Splitting is done in two passes: burst to one file per page with
Robomotion.PDFBox.Split, then merge the two halves withRobomotion.PDFBox.Merge. This keeps the split point a simplelist.slice(0, n)/list.slice(n)decision driven by sorted filenames. - Output filenames are
<stem>-1.pdf/<stem>-2.pdf(with a hyphen, not an underscore) placed alongside the source in the timestampedsplit_parts_<stamp>directory so repeated runs never overwrite earlier output. - If the chosen split page is at or past the last page, the
Plan Halvesvalidator routes toCore.Flow.Stoprather than producing an empty second half.
More pdf templates
See all 9 →- Create PDF from Selected PagesPulls a chosen range of pages from a source PDF and writes them to a new document. Useful for trimming or sharing parts of a report.
- Extract Tables from PDFLocates tables inside a PDF and extracts their rows into structured data. A drop-in stage in any OCR-adjacent pipeline.
- Get Images from PDFExtracts every embedded image from a PDF file into a target directory. Useful for downstream OCR or asset recovery.
- Get Number of Pages in a PDFReports the page count of a PDF file as a single number. A small utility that feeds splitters, paginators, and dashboards.
- Merge PDFsCombines every PDF in a folder into one consolidated document using a reusable merge subflow.
- Merge Two PDFsJoins two PDF files into a single output document — the minimal merge recipe.