Skip to main content
Legend
December 15, 2017
Answered

Extract single page pdfs with specific names

  • December 15, 2017
  • 1 reply
  • 3207 views

I want to create a acrobat action to extract single page pdfs to specific names. first I'am using the "Search and Remove Text" under Protection to find the text to be used for the individual file naming. This creates Comments for each page with the unique text for the names. Then I want to use javascript to to do the extracting.

I found this code on the forum that extracts single page pdfs. I need the extracted pdfs named by the Contents............ Annots:/ Redacts:/ Contents: with the Annots removed.

I've tried to modify the code with no luck. I am new to scripting, I understand the concept I just don't know the method/properties to perform the function to apply the Annots Contents from each page to the naming of each extracted pdf.

code that extracts single page pdfs.

    var re = /.*\/|\.pdf$/ig;

    var filename = this.path.replace(re,"");

    {

        for ( var i = 0;  i < this.numPages; i++ )

        this.extractPages ({ nStart: i, nEnd: i, cPath : filename + "_page_" + (i+1) + ".pdf"});

    };

Thanks in advance for any help!!

This topic has been closed for replies.
Correct answer try67

Yes that would be great!

Thanks!


Try this version:

this.syncAnnotScan();

var annots = this.getAnnots();

if (annots!=null) {

    for (var i=annots.length-1; i>=0; i--) {

        var annot = annots;

        if (annot.type=="Redact") {

            var newFilePath = this.path.replace(this.documentFileName, annot.contents + ".pdf");

            var p = annot.page;

            annot.destroy();

            this.extractPages(p, p, newFilePath);

        }

    }

}

1 reply

try67
Community Expert
Community Expert
December 15, 2017

So you have a Redaction annotation on each page with the name you want to use for that page as its contents?

Mike BroAuthor
Legend
December 15, 2017

Thats correct!

try67
Community Expert
Community Expert
December 15, 2017

Is there only one such annotation per page? Do you want to do the extraction in a separate process, or as a part of the Action?