Print Page | Close Window

How to extract blank pages into a merged PDF doc?

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=62
Printed Date: 21 Sep 2019 at 6:23am
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: How to extract blank pages into a merged PDF doc?
Posted By: oald
Subject: How to extract blank pages into a merged PDF doc?
Date Posted: 12 Oct 2011 at 5:36pm

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://forums.planetpdf.com/uploads/151/Test_1.pdf - uploads/151/Test_1.pdf
 
Hers is the analysis report which I want to generate by JavaScript:
http://forums.planetpdf.com/uploads/151/Analysis_report_of_Test_1.pdf - uploads/151/Analysis_report_of_Test_1.pdf



Replies:
Posted By: aandi
Date Posted: 12 Oct 2011 at 7:48pm
One thought: you could make a list of the pages to be extracted, then extract ALL pages. Then delete all the pages that are NOT to be extracted from the NEW extracted file, leaving only the (presumed) blanks?  Not entirely sure this can work, not sure if the new file will have the disclosed flag set.


Posted By: oald
Date Posted: 20 Oct 2011 at 9:24am
aandi, thanks for your suggestion, I make it! Your help is really appreciated!

-------------
My Product Information:
Acrobat Pro 8.1.6, Windows



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net