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.
Printed Date: 17 Feb 2020 at 8:35pm
Software Version: Web Wiz Forums 11.10 -

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)
var fileName = this.documentFileName;
if (blankpages.length != 0)
    var rep = new Report();
    rep.size = 1.6;
    rep.color =;
    rep.writeText("Pages " + blankpages + " are blank pages.");"Analysis report of " + fileName);

Here is an example file which I want to process: - uploads/151/Test_1.pdf
Hers is the analysis report which I want to generate by JavaScript: - uploads/151/Analysis_report_of_Test_1.pdf

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 -
Copyright ©2001-2017 Web Wiz Ltd. -