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

Acrobat JavaScript - Batch Delete

New Here ,
Jun 08, 2017 Jun 08, 2017

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

TOPICS
Acrobat SDK and JavaScript
1.8K
Translate
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

correct answers 1 Correct answer

Community Expert , Jun 08, 2017 Jun 08, 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);

}

Translate
Community Expert ,
Jun 08, 2017 Jun 08, 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);

}

Translate
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 ,
Jun 08, 2017 Jun 08, 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"

}

Translate
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 ,
Jun 08, 2017 Jun 08, 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>

Translate
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 ,
Jun 08, 2017 Jun 08, 2017
LATEST

Okay,  Thanks for your help.

Translate
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 ,
Jun 08, 2017 Jun 08, 2017

In the save step of the action you can specify the suffix.

Translate
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