Skip to main content
Participant
June 8, 2017
Answered

Acrobat JavaScript - Batch Delete

  • June 8, 2017
  • 1 reply
  • 1961 views

Hi Guys

I would be grateful for some help with this as new to javascript.

Im looking to create an action within acrobat to batch delete pages. These PDF documents are varied with the total number of pages. I would like to delete all pages but keep the first and last two pages within the document, so 4 pages remaining after running the script.

Thanks

Alex

This topic has been closed for replies.
Correct answer try67

If you have Acrobat Pro create a new Action and have it execute this code, and a Save command:

if (this.numPages>4) {

    this.deletePages(2,this.numPages-3);

}

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 8, 2017

If you have Acrobat Pro create a new Action and have it execute this code, and a Save command:

if (this.numPages>4) {

    this.deletePages(2,this.numPages-3);

}

Participant
June 8, 2017

Thank you for your help.

One more thing, I would like to be able to save it as a new file adding 'aprf1' at the end of the PDF after action is complete. Here's what I have done, but it doesn't seem to be working.

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

if (this.numPages>4) { 

    this.deletePages(2,this.numPages-3); 

cPath : filename + "_aprf1" + ".pdf"

}

try67
Community Expert
Community Expert
June 8, 2017

Look at the options of the Save command. You can set it up there.

On Thu, Jun 8, 2017 at 2:50 PM, Shankster118 <forums_noreply@adobe.com>