PDF Editing Issues

How to Extract PDF Pages Using an Acrobat Pro Button Script

Tauseeq MagsiTauseeq Magsi Nov 5, 2026 869 views

Question details

The user needs to extract a continuous page range or selected nonsequential pages using an Acrobat Pro button script and save them to a specific destination folder.

How to Extract PDF Pages Using an Acrobat Pro Button Script
Product
Adobe Acrobat Pro
Device & OS
not provided
Scenario
Automating the extraction and saving of specific pages from a PDF document using JavaScript assigned to a custom form button.
Observed behavior
The user wants to configure a script that successfully isolates the desired pages and manages the file saving process either manually or automatically via predefined paths.
Before you start

Ensure you have Adobe Acrobat Pro installed and have basic familiarity with the Prepare Form tool, as executing custom JavaScript requires form-editing capabilities.

Solution 1Recommended

Use the extractPages Method in a Button Script

Assign a document-level JavaScript utilizing the extractPages method to an interactive button to pull out the specified pages.

Acrobat Pro allows users to attach JavaScript actions to form fields. By using the document-level `this.extractPages(start, end);` method, you can trigger Acrobat to extract a specified range of pages into a new, unsaved PDF document.

It is crucial to remember that Acrobat JavaScript uses zero-based page indexing. This means the first page of your PDF is index 0. If you wish to extract pages 27 through 32, you must subtract one from each page number in your script.

1
Enter Form Editing Mode

Open your PDF in Acrobat Pro, navigate to the Tools menu, and select 'Prepare Form' to enable form editing.

2
Add a Custom Button

Click the 'Add a Button' icon in the top toolbar, place the button on your document, and double-click it to open the Button Properties dialog.

3
Assign a JavaScript Action

Navigate to the 'Actions' tab. Select 'Mouse Up' from the Select Trigger dropdown, choose 'Run a JavaScript' from the Select Action dropdown, and click 'Add'.

4
Write the Extraction Script

In the JavaScript Editor, enter your code. To extract pages 27 through 32, type: `this.extractPages(26, 31);` and click 'OK'.

5
Test the Button

Close the form editor. Click your newly created button. Acrobat will extract the requested pages into a new PDF window, allowing you to manually save the file.

Use the extractPages Method in a Button Script
Automating File Saves: A basic button script only extracts the pages. To automatically save the extracted file to a custom folder path without a prompt, you must create and install a trusted folder-level script on your computer due to Adobe's strict security restrictions on local file writing.
Easy PDF Solution

Extract PDF Pages Easily Without Scripts Using WPS Office

If you need to extract continuous or nonsequential pages but want to avoid writing complex JavaScript and configuring folder-level security bypasses, WPS Office provides an intuitive Page Extraction tool. You can visually select pages and save them directly to any folder in seconds.

  1. 1. Open the PDF File: Launch WPS Office and open the PDF document from which you want to extract pages.
  2. 2. Navigate to Page Management: Click on the 'Page' tab located in the top ribbon menu to view the page management tools.
  3. 3. Select the Extract Tool: Click the 'Extract Page' button to open the extraction dialog box.
  4. 4. Define the Page Range: Select 'Custom page range' and type your desired pages directly (e.g., '27-32' for sequential, or '27, 32' for nonsequential pages) without worrying about zero-based indexing.
  5. 5. Extract and Save: Set your destination folder in the output options and click 'Extract' to instantly create and save your new PDF.
Extract continuous and nonsequential pages effortlessly with a few clicks.No coding, JavaScript, or folder-level script configuration required.Fully compatible with standard PDF documents and formatting.Directly define your output folder and file name from an intuitive GUI.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my Acrobat script extract the wrong page number?

Acrobat JavaScript relies on zero-based indexing. This means page 1 is treated as index 0, page 2 as index 1, and so forth. If you want to extract page 5, you must use the number 4 in your extractPages method.

Can I extract nonsequential pages with a single script command?

The extractPages() method is designed for sequential ranges (start index to end index). To extract scattered, nonsequential pages (like page 27 and page 32), you generally need to extract them individually and then use script methods to merge them, or handle it manually.

Why doesn't my script save the extracted PDF to my folder automatically?

For security reasons, Adobe prevents document-level JavaScript from silently writing files to your local hard drive. To achieve automated saving without a prompt, you must deploy a trusted folder-level script (a .js file placed in Acrobat's internal Privileged folder) that elevates the script's permissions.