Function that will auto detect and delete blank pages?

New Here ,
Feb 06, 2019

Copy link to clipboard

Copied

I have no experience writing java, I'm in need of a function that will auto detect and delete blank pages in large documents. I have yet to find any other way to automate this.

Thanks!

TOPICS
Acrobat SDK and JavaScript, Windows

Views

152

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Function that will auto detect and delete blank pages?

New Here ,
Feb 06, 2019

Copy link to clipboard

Copied

I have no experience writing java, I'm in need of a function that will auto detect and delete blank pages in large documents. I have yet to find any other way to automate this.

Thanks!

TOPICS
Acrobat SDK and JavaScript, Windows

Views

153

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 06, 2019 0
Most Valuable Participant ,
Feb 06, 2019

Copy link to clipboard

Copied

Java and JavaScript are not the same thing... Only the latter can be used within Acrobat, and it can only detect if a page has no text (or objects such as fields, links, comments, etc.) on it, not things like images or graphics. If that's alright with you then it can be done using a fairly simple script.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2019 0
New Here ,
Feb 06, 2019

Copy link to clipboard

Copied

Sorry, I didn't realize they were different, but yes that's what I need. Do you have a script I can use?


Thank you!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2019 0
Most Valuable Participant ,
Feb 06, 2019

Copy link to clipboard

Copied

What version of Acrobat do you have?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2019 0
New Here ,
Feb 06, 2019

Copy link to clipboard

Copied

Adobe Acrobat DC 19.010.20069

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2019 0
Adobe Community Professional ,
Feb 06, 2019

Copy link to clipboard

Copied

The number of words on a page is provided by the function "this.getPageNumWords()".

But there is another way. A truly blank page will have an empty bounding box. The "this.getPageBox("BBox") will return a rectangle with zero area.

However, for detecting blank pages both of these methods are seriously flawed. Automatically generated documents will often have headers and footers that should not be counted, and OCR on scanned documents will often mark image artifacts as characters or content.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2019 1
Most Valuable Participant ,
Feb 06, 2019

Copy link to clipboard

Copied

Also, a simple scanned document contains a large image, even on blank pages, so the bounding box test cannot be used (nor any other test). Scanning also adds another complication even if writing a plug-in (very advanced!) since the scanned "blank" sheet is never simply white pixels.

In essence, banapol, I recommend you give up the idea.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2019 0
try67 LATEST
Most Valuable Participant ,
Feb 06, 2019

Copy link to clipboard

Copied

Despite all the correct comments provided above, if you still want to do it based only on the number of words on a page, you can use this code:

for (var p=this.numPages-1; p>=0; p--) {

    var numWords = this.getPageNumWords(p);

    if (numWords==0) {

        if (this.numPages==1) {

            app.alert("Error! Can't delete the last page of the file.");

        } else this.deletePages(p,p);

    }

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 06, 2019 0