Skip to main content
Question

Merging Multiple PDF documents A360

  • Mar 22, 2024 8:55 PM UTC
  • 8 replies
  • 718 views

Forum|alt.badge.img+7

Using A360, I am struggling to merge multiple pdf documents. The exact number of documents is variable. Therefore, the activity PDF: Merge Documents is not suitable because it requires the bot developer to declare ahead of time the documents to merge. I’ve even tries the bot store PDFUtils. The “Merge all PDF files” action works, however I can’t sort which order the documents should be merged into, so the final file shows out of page order. I’ve also tried the PDFUtils: Merge PDF files but receive an error as if the package is not working correctly. 

 

Thank you very much for any help and advice! It is greatly appreciated as this issue has stalled bot development for our use case.

8 replies

Forum|alt.badge.img
  • Cadet | Tier 2
  • Jul 24, 2024 1:39 PM UTC

Hi Jaye,

 

You can try to use the Merge Documents action in a loop. Iterate through the directory containing your files that you would like merged and add an if else statement “If <merged document path> does not exist, copy the current file in the iteration to the merged doc path; else merge documents: merged doc path + current file in iteration.

 

Although this runs slowly, it works. Also, you would have to already have your files in the directory listed in the order that you wanted. 

 

On another note, I saw your post as I was looking for information the PDF Utilities Merge All PDFs action. Whenever I use this, it just copies the first PDF over and over so I have a merged file of just the first PDF repeated. Have you encountered this using that action?

 

Thanks


Forum|alt.badge.img
  • Navigator | Tier 3
  • Jul 26, 2024 6:50 PM UTC

@jaye check my comment here: 

 


Forum|alt.badge.img
  • Flight Specialist | Tier 4
  • Aug 16, 2024 5:13 PM UTC

We solved for this by determining the max number of possible pdf files and then created a taskbot with that number of input variables to hold the names of the files. In this task bot we check for the number of files coming an and use an IF statement to determine the merge action that runs. Under each IF there is a merge action with than number of files to be merged and the input variables.

We call that taskbot from our main bot and map in the number of files and the file names (with paths) into the input variables.

It’s a nice solution and we can re-use this taskbot in all of our BOTs that need this kind of thing!


Forum|alt.badge.img
  • Flight Specialist | Tier 4
  • Aug 16, 2024 5:17 PM UTC

I suppose you could do a similar thing like I outlined above in a loop if you passed back the full path and name of the resulting merged file.

  1. Pass in two files to start
  2. Bring back the full path to the merged file in an output variable
  3. Use that file name and the NEXT file to be merged as new input back into the taskbot 
  4. Repeat until you have looped through all files that need to be merged

Taskbot that loops through a folder of PDF files:

Main Taskbot is mapped to merge taskbot like this:

 


  • Cadet | Tier 2
  • Oct 31, 2026 9:48 AM UTC

To merge multiple PDF documents, you can use this free extension (https://chromewebstore.google.com/detail/pdf-champ-free-pdf-tools/cakbepehbnckifldldinacgpnienicea)


Dineshkumar Muthu
Flight Specialist | Tier 4
Forum|alt.badge.img+1

.


KhaledMostafaMe
Most Valuable Pathfinder
Forum|alt.badge.img+2
  • Most Valuable Pathfinder
  • Nov 12, 2026 8:23 PM UTC

@jaye  You're right that the file count changes every run, and the "Merge all PDF files" action gives you no place to set an order. Both problems have the same fix: build the list of files at runtime, in the sequence you want, and merge that list.

You don't need to know the number of PDFs at design time. Build a list of paths in the right order, then merge that list in one step.

The idea is to separate "which files, in what order" from "the merge itself."

  1. Variable number of files: The PDF package's Merge documents action has no fixed file limit. The real limits are memory, page count and file size. Loop over your folder and add each path to a list variable, so the bot never needs a fixed set of named inputs. Flow: Loop folder (*.pdf) ➔ Add path to list ➔ Merge list

  2. Page order: "Merge all PDF files" only takes a directory and an output path, so the order is whatever the folder gives it. Control the order yourself by naming files with a sortable prefix (001_, 002_) or by arranging the list before the merge. A forum member reports that a PDF Box package's merge action accepts a list of file paths and keeps that order: this thread.

  3. The "Merge PDF files" error: I can't tell the cause from your post alone. Two things commonly cause it. One is an owner-protected PDF; the Merge all action fails on those even when you can open the file. The other is an XFA form from Adobe LiveCycle Designer, which the Merge documents action can't combine. Paste the full error text, and tell me which PDF or folder it fails on.

 


KhaledMostafaMe
Most Valuable Pathfinder
Forum|alt.badge.img+2
  • Most Valuable Pathfinder
  • Nov 13, 2026 7:57 AM UTC

@jaye  Since the earlier reply, the one new thing I'd add is a Bot Store package you can test against your folder before you build the loop yourself.

Use the PDF Utilities Package's two-file merge inside your ordered loop. That gives you control over page order, which the "Merge all PDF files" action does not.

The package is free and lists two merge routes: "Merge all PDF files in a directory" and "Merge two PDF files". The second one takes two files at a time, so you can run it inside your loop. Pass each merged result back in as the first file, then add the next file from your ordered list. Its public page is PDF Utilities Package on the Bot Store.

  1. Ordering the files: Name the files with a sortable prefix such as 001_, 002_, or build the list in the sequence you want before the loop starts. The loop then follows that list, not the folder's default order.

  2. Chaining the merge: Loop over ordered list ➔ Merge two PDF files (current result + next file) ➔ Save result as merged.pdf. This avoids the all-in-one action that gives no order control.

If the "Merge PDF files" error still appears with this package, paste the full error text here and tell me whether it fails on the first pair or the last. That will show whether the problem is the package or one of the PDFs, such as an owner-protected file.

Happy to go deeper on the loop if you post your list-building step.