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

Can I use a script on a button in Acrobat (Pro) to extract a range of pages in a pdf?

Community Beginner ,
Apr 29, 2021 Apr 29, 2021

Copy link to clipboard

Copied

Hi, I'm trying to create a button with a command to extract pages from a pdf.  I need 2 buttons, one to extract a run of pages (27-32) and another button to extract 2 non sequential pages (27 & 32)  I've been reading various forums and found some comments related to using the Console and one comment said "Extracting pages is for automation, not document interactivity. Automation scripts include JavaScript code run from the JavaScript Console, a Batch Process, or a Folder Level Script."

 

I have a pdf that I complete regularly, but then need to extract two sets of pages from the file and save in the same destination with the same file name but add "Client Copy 1" and "Client Copy 2" to the file name.  Can this be done using script on a button?

 

If this is too complicated to arrange a file name, could it simply extract the relevant pages ready for me to then 'save as'  This simple automation would help if it can be done?

Thanks.

TOPICS
How to , JavaScript , PDF forms

Views

675

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

correct answers 1 Correct answer

Community Expert , Apr 29, 2021 Apr 29, 2021

So the "doc.extractPages" function will work in Acrobat Pro from a document script, so you can run it from a button on a PDF. However, since this is only for you, you can put a folder level script on your own system that will save the extracted pages to a predetermined file name and folder path.  

 

here's the basic button script for just extracting the pages, but not saving

 

this.extractPages(1,3);

 

This code extracts pages 2 to 4 from the document. 

 

 

Votes

Translate

Translate
Community Expert ,
Apr 29, 2021 Apr 29, 2021

Copy link to clipboard

Copied

So the "doc.extractPages" function will work in Acrobat Pro from a document script, so you can run it from a button on a PDF. However, since this is only for you, you can put a folder level script on your own system that will save the extracted pages to a predetermined file name and folder path.  

 

here's the basic button script for just extracting the pages, but not saving

 

this.extractPages(1,3);

 

This code extracts pages 2 to 4 from the document. 

 

 

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
Community Beginner ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

Hi Thom, this works perfectly, thank you.  What would the code be to extract non sequential pages, is that possible?

 

I need pages 27 & 32 for example from a 32 page document.

 

Thanks.

 

Phil

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 ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

No. If you want to do it like that the options are:

- Create a new document and then import those pages into it, or

- Delete all the other pages in the file.

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 Beginner ,
Apr 30, 2021 Apr 30, 2021

Copy link to clipboard

Copied

LATEST

That's a shame, thanks very much for the response, much appreciated.  🙂 Have a good weekend.

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