These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to extract blank pages into a merged PDF document

oald
Registered: Oct 12 2011
Posts: 17
Answered

I'm developing a tool to extract all blank pages (for this tool, I regard pages without text as blank pages, although there may be other objects in them) or not OCRed pages to a merged PDF, also I want to insert a analysis result page to the first page of the merged PDF. The codes below can create an "Analysis Report" with the first page stating "Pages X,X,X,X... are blank pages.", but I don't know how to the extract the blank pages to the consecutive pages of the "Analysis Report", and how to insert bookmarks "Page X", "Page X" (X means the blank page number in the original document), I check the JS reference and find that there is a method "extractPages", but it can only extract a continuous page range. Can anyone kindly help me? Your help is really appreciated!
  
var blankpages = new Array();
for (var k = 1; k <= this.numPages; k++)
{
numWords = this.getPageNumWords(k-1);
if (numWords == 0)
{
blankpages.push(k);
}
}
 
var fileName = this.documentFileName;
if (blankpages.length != 0)
{
var rep = new Report();
rep.size = 1.6;
rep.color = color.blue;
rep.writeText("Pages " + blankpages + " are blank pages.");
rep.open("Analysis report of " + fileName);
app.execMenuItem("ShowHideBookmarks");
}
 
Here is an example file which I want to process:
http://g.zhubajie.com/urllink.php?id=11690845l9cnk3fqe5779ubz
 
Hers is the analysis report which I want to generate by JavaScript:
http://g.zhubajie.com/urllink.php?id=11690849jycqmypg87dmqm60

My Product Information:
Acrobat Pro 8.1.6, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
What you're missing is the following: when you close the report (by using the open() method, of all things...) it returns a Doc object, which you can save as a variable. At that point you can use it like any other document.
What you can then do is use the insertPages() method to insert all of the blank pages you've identified at the end of your new doc. You might need to first close the original document, though.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com