All templates
PDFBeginner
Merge Two PDFs
Robomotion•Updated 6 months ago

Overview
Joins two PDF files into a single output document — the minimal merge recipe.
Merge Two PDFs
PDF manipulation is an ideal candidate for automation, as many scenarios, such as merging reports, require strictly standardized steps. Robomotion provides a series of PDF nodes to automate these tasks and handle PDF files efficiently.
What Merge Two PDFs can do
Download Fixturessubflow thenBuild Defaults(Core.Programming.Function) setsmsg.default_first,msg.default_second,msg.default_destunder$Home$/templates/pdf-automation/merge-two-pdfs/fixtures.- Three
Core.Dialog.InputBoxprompts titledMerge two PDFs into one.collectmsg.first_doc,msg.second_doc, andmsg.destination_folderusing the defaults above. Validate Inputs(Core.Programming.Function,outputs: 2) — short-circuits toCore.Flow.Stopif any path is empty; otherwise buildsmsg.pdf_paths = [msg.second_doc, msg.first_doc]and seedsmsg.candidate_pathas<dest>\MergedFile.pdf.Core.FileSystem.Createensures the destination directory exists, then aCore.Flow.Label/Core.FileSystem.PathExistsloop incrementsmsg.suffix_idxuntilmsg.candidate_pathis free and stores it asmsg.merged_path.Robomotion.PDFProcessor.Core.Mergewritesmsg.pdf_pathstomsg.merged_path, thenCore.Dialog.MessageBoxtitledDone!shows the final path viamsg.dialog_text.
Behind the scenes
- The merge node receives a real array (
msg.pdf_paths), not a delimited string —Robomotion.PDFProcessor.Core.Mergeexpects an array of paths. - Note the order swap:
msg.pdf_pathslists the second document first, then the first. This preserves the reversed-list convention from the original tutorial. - The suffix loop guarantees we never overwrite an existing
MergedFile.pdf; subsequent runs land onMergedFile_2.pdf,MergedFile_3.pdf, etc. - The success dialog surfaces the full merged-file path (
msg.merged_path), so the user can locate the exact output even when the suffix loop renamed it.