All templates
PDFAdvanced
Split PDF by Half
Robomotion•Updated 9 months ago

Overview
Calculates a midpoint and splits a PDF into two evenly-sized halves. Demonstrates arithmetic on page counts feeding a splitter.
Split PDF by Half
Apart from dividing PDF files using a user-defined splitting point, Robomotion enables the implementation of fully automatic logic that doesn't require user input, like always splitting PDF files in half.
What Split PDF by Half can do
- Build default path (
Core.Programming.Function) — setsmsg.default_pdfto the bundledsample.pdfunder$Home$/templates/pdf-automation/split-pdf-by-half/fixtures. - Input Dialog titled
Split a PDF by half, messageSelect a PDF file to split:, defaultmsg.default_pdf→msg.pdf_path. - Branch On Cancel (
Core.Programming.Function,outputs: 2) — routes toCore.Flow.Stopunlessmsg.pdf_pathends with.pdf. - Derive Paths (
Core.Programming.Function) — splits the file path intomsg.directoryand buildsmsg.split_output_diras<directory>\split_halves_<timestamp>. - Get Page Count / Compute Half (
Core.Flow.SubFlow) — populatemsg.page_countandmsg.half. - Plan Split (
Core.Programming.Function,outputs: 2) — stops whenpage_count < 2; otherwise setsmsg.custom_pages = [msg.half + 1]. - Ensure Split Dir (
Core.FileSystem.Create,optType: directory,continueOnError: true) formsg.split_output_dir. - Split At Midpoint (
Robomotion.PDFProcessor.Core.Split) —inPDFPath: msg.pdf_path,inDir: msg.split_output_dir,optCustomPages: msg.custom_pages. - Build Done Text +
Core.Dialog.MessageBox(info, titleFlow has been completed!) showing the output directory.
Behind the scenes
- For odd
msg.page_count,msg.half = (count - 1) / 2, so the second half gets the extra page. Flip the subflow if you prefer the opposite convention. page_count < 2short-circuits toCore.Flow.StopinPlan Split— there's no separate handling for0or1-page PDFs.Ensure Split Dirruns withcontinueOnError: trueso re-running the flow against an existing timestamped directory doesn't fail.
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.