How to Save Selected PDF Page Ranges as Separate Files
Question details
The user needs to divide a PDF form into separate files by extracting specific page ranges using JavaScript.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Automating the extraction of specific page ranges from a PDF document to save them as separate files, potentially triggering the action from a form button.
- Observed behavior
- Using a document-level script to silently save extracted pages fails because saving files to arbitrary locations requires elevated security privileges.
Ensure you have a backup copy of your original PDF form before running scripts. You should also verify that you have administrative access to configure trusted folder-level scripts if you plan to execute the extraction from a PDF form button.
Use the Acrobat JavaScript Console for Page Extraction
Execute a straightforward script via the console window to quickly extract a page range into a separate document.
Launch Adobe Acrobat and open your PDF document. Press Ctrl+J on Windows or Cmd+J on Mac to open the JavaScript Console.
Type the extraction command into the console. For example, to extract the first two pages, type: this.extractPages(0,1,'PDF-Document1.pdf');
Highlight the script you just typed and press Ctrl+Enter (or Cmd+Enter on Mac) to run it. The specified pages will be extracted and saved.

Configure a Folder-Level Script for Form Buttons
Create a trusted folder-level script to bypass security restrictions when triggering page extraction directly from a PDF form button.
Extract and Split PDF Pages Visually with WPS Office
Avoid complex JavaScript configurations and security workarounds. WPS Office provides an intuitive, built-in tool that lets you extract specific page ranges and save them as separate files in just a few clicks.
- 1. Open the PDF in WPS Office: Launch WPS Office and open the PDF document you want to split or extract pages from.
- 2. Navigate to the Page tool: Click on the 'Page' tab located in the top navigation menu to reveal page management tools.
- 3. Select Extract Page: Click the 'Extract Page' or 'Split PDF' option from the ribbon menu.
- 4. Configure and save: Choose the specific page ranges you need, select your destination folder, and click 'Extract' to save them instantly as separate files.

Frequently Asked Questions
Why does my PDF extraction script fail to save the file automatically?
Document-level JavaScript runs in a secure sandbox and cannot silently save extracted pages to an arbitrary location on your hard drive. You must use a trusted folder-level script to grant the necessary privileged access for saving files.
How does page numbering work in Acrobat JavaScript?
Acrobat JavaScript uses a zero-based index for referencing pages. This means the first page of the document is index 0, the second page is index 1, and so on.
Can I trigger a page extraction script from a button within the PDF?
Yes, but you cannot use a simple document-level script attached to the button if the action involves saving a file directly. You must reference a trusted folder-level script installed on the local machine to securely bypass file-saving restrictions.




