• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Function that will auto detect and delete blank pages?

New Here ,
Feb 06, 2019 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

590

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
community guidelines
Community Expert ,
Feb 06, 2019 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.

Votes

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
community guidelines
New Here ,
Feb 06, 2019 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!

Votes

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
community guidelines
Community Expert ,
Feb 06, 2019 Feb 06, 2019

Copy link to clipboard

Copied

What version of Acrobat do you have?

Votes

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
community guidelines
New Here ,
Feb 06, 2019 Feb 06, 2019

Copy link to clipboard

Copied

Adobe Acrobat DC 19.010.20069

Votes

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
community guidelines
Community Expert ,
Feb 06, 2019 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.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
LEGEND ,
Feb 06, 2019 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.

Votes

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
community guidelines
Community Expert ,
Feb 06, 2019 Feb 06, 2019

Copy link to clipboard

Copied

LATEST

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);

    }

}

Votes

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
community guidelines