Batch Merge PDF

Can I merge single PDFs into a multi-page PDF using a batch process?


Gerald Galbreath


Voted Best Answer

This is possible, but with some constraints. When the batch (or actions) process is processing a file, it does not know anything about any of the other files it has or will process. So, to create a merge batch or action, you have to jump through a few hoops to get e.g, information about the target document.

Let's approach this from a different angle: Why do you want to do a batch merge? You are talking about "Batch", so I assume you are using Acrobat 9. There is a File>Combine>Merge Files into a single PDF feature that allows you to select our source files and will generate a merged target file. Is that not sufficient? What would a batch process give you that you cannot do with this function?

If you really want to go ahead with a batch merge, you would do this with JavaScript: Add one JavaScript processing step to your batch sequence and use something like the following script:

/* Merge all documents selected into one document */// do we have an active document with the title "MergeResults"
var f = null;
var fileIsNew = false;
var d = app.activeDocs;
for (var i=0; i < d.length; i++)
if (d[i].info.Title == "MergeResults")
{
f = d[i];
}


if (f == null)
{
// create the merge results document - this will add a blank page that we need to remove later
f = app.newDoc();
f.info.Title = "MergeResults";
fileIsNew = true;
}


// append the current document to MergeResults
f.insertPages(f.numPages-1, this.path);


if (fileIsNew)
{
// remove the first page
f.deletePages();
}


Karl Heinz Kremer

PDF Acrobatics Without a Net

PDF Software Development, Training and More...

http://www.khkonsulting.com


By Karl Heinz Kremer   


Please specify a reason: