When I use batch processing and javascript to merge a PDF to different background PDFs (I have a large PDF of 4000 pages that contains 1000 documents, each that merges to a specific background PDF), it takes a very, very long time. I have to break up my original PDF into much smaller PDFs and run the batch on each PDF. Then I combine the PDFs into one large PDF to send off for production. Is there a way that I can speed up the batch process so I don't have to split and recombine? Here is the code:
var ckWord, numWords, pgNum, mastVersion;
for (var p = 0; p < this.numPages; p++)
{
j=0;
mastVersion = " ";
ckWord = " ";
while (mastVersion != "MASTHEAD")
{
mastVersion = this.getPageNthWord(p,j).substring(0,8);
//app.alert("mastVersion="+mastVersion);
j++
}
mastVersion= this.getPageNthWord(p,j-1).substring(0,9);
//app.alert("mastVersion="+mastVersion);
j=0;
while (ckWord != "MERGEKEY")
{ckWord = this.getPageNthWord(p,j).substring(0,8);
//app.alert("ckWord="+ckWord);
j++
}
if (ckWord == "MERGEKEY")
{
pgNum= this.getPageNthWord(p,j-1).substring(8,11);
//app.alert("pgNum="+pgNum)
if (mastVersion == "MASTHEAD1")
{
this.insertPages(p, "/C/Premier Mastheads Testing/Premier_WEB_12pgr_July31.pdf", pgNum-1);
this.createTemplate("onepage", p);
op = this.getTemplate("onepage", p);
op.spawn(p+1, true, true);
this.deletePages(p);
this.removeTemplate("onepage");
}
if (mastVersion == "MASTHEAD2")
{
this.insertPages(p, "/C/Premier Mastheads Testing/Premier_PRINT_12pgr_July31.pdf", pgNum-1);
this.createTemplate("onepage", p);
op = this.getTemplate("onepage", p);
op.spawn(p+1, true, true);
this.deletePages(p);
this.removeTemplate("onepage");
}
if (mastVersion == "MASTHEAD3")
{
this.insertPages(p, "/C/Premier Mastheads Testing/Premier_WEB_8pgr_PMS_July31.pdf", pgNum-1);
this.createTemplate("onepage", p);
op = this.getTemplate("onepage", p);
op.spawn(p+1, true, true);
this.deletePages(p);
this.removeTemplate("onepage");
}
if (mastVersion == "MASTHEAD4")
{
this.insertPages(p, "/C/Premier Mastheads Testing/Premier_PRINT_8pgr_July31.pdf", pgNum-1);
this.createTemplate("onepage", p);
op = this.getTemplate("onepage", p);
op.spawn(p+1, true, true);
this.deletePages(p);
this.removeTemplate("onepage");
}
if (mastVersion == "MASTHEAD5")
{
this.insertPages(p, "/C/Premier Mastheads Testing/Premier_PRINT_4pgr_July31.pdf", pgNum-1);
this.createTemplate("onepage", p);
op = this.getTemplate("onepage", p);
op.spawn(p+1, true, true);
this.deletePages(p);
this.removeTemplate("onepage");
}
if (mastVersion == "MASTHEAD6")
{
this.insertPages(p, "/C/Premier Mastheads Testing/Premier_WEB_FRE_12pgr_Aug10.pdf", pgNum-1);
this.createTemplate("onepage", p);
op = this.getTemplate("onepage", p);
op.spawn(p+1, true, true);
this.deletePages(p);
this.removeTemplate("onepage");
}
if (mastVersion == "MASTHEAD7")
{
this.insertPages(p, "/C/Premier Mastheads Testing/Premier_WEB_FRE_8pgr_Aug10.pdf", pgNum-1);
this.createTemplate("onepage", p);
op = this.getTemplate("onepage", p);
op.spawn(p+1, true, true);
this.deletePages(p);
this.removeTemplate("onepage");
}
if (mastVersion == "MASTHEAD8")
{
this.insertPages(p, "/C/Premier Mastheads Testing/Premier_PRINT_FRE_4pgr_Aug10.pdf", pgNum-1);
this.createTemplate("onepage", p);
op = this.getTemplate("onepage", p);
op.spawn(p+1, true, true);
this.deletePages(p);
this.removeTemplate("onepage");
}
}
}
My Product Information:
Acrobat Pro 7 / Windows
Offline

First, it would be much easier to use the "doc.addWatermarkFromFile" to place the background.
Since you already know what file is the background for which page, you could write a script to automate the whole thing. No batch process necessary. Run it from a folder level script.
Offline
Hi Thom,
Thanks for your response. I am trying to enter this code using folder level scripts. I am basically copy and pasting my code into the console. I am having trouble directing these commands to the PDF i want my other PDFs to merge to.
Before the code (written above), I am entering:
app.openDoc("/C/test.pdf");
When doing this I get an undefined error.
Am I missing some code to get the above script to act on a specific PDF
Offline
AcrobatUsers.com >> User Groups • News • Events • Articles • Blogs • How To • Resources • Member Log in