PDF Editing Issues

Save Extracted PDF Pages with Adobe Acrobat JavaScript

Jason MillerJason Miller Nov 19, 2026 869 views

Question details

The user wants to extract PDF pages with JavaScript, name the resulting files, and open Save As when needed.

Save Extracted PDF Pages with Adobe Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A beginner is automating PDF page extraction and needs to control how the output is saved.
Observed behavior
The goal is to save extracted pages under chosen filenames or let the user choose a filename in Save As.
Before you start

Open the source PDF in desktop Adobe Acrobat and check that its security settings permit page extraction. These examples use Acrobat JavaScript APIs, not browser JavaScript; programmatic file saving may require a trusted or otherwise privileged context.

Solution 1Recommended

Extract Pages and Save the New PDF Programmatically

Use Acrobat JavaScript to create a PDF from selected pages and save it under a specified filename.

Page indexes start at 0, so page 1 is index 0. The extractPages() method can also accept an optional cPath to save the extracted pages directly.

1
Open the source PDF

Open the PDF in Adobe Acrobat and use a trusted Acrobat JavaScript context appropriate for your workflow.

2
Extract the pages

In your Acrobat JavaScript, create a document from the first page: var extracted = this.extractPages({nStart: 0, nEnd: 0}); Change the indexes to select a different range.

3
Save with a filename

Call extracted.saveAs("/path/to/output.pdf"); using a valid Acrobat device-independent path to an existing folder. Change the filename for each output PDF.

Extract Pages and Save the New PDF Programmatically
Saving permissions: Acrobat restricts programmatic saving in some JavaScript contexts. If saveAs() or the cPath option is blocked, use a permitted privileged context, such as an appropriately configured trusted function. Acrobat Reader and secured PDFs may have additional restrictions.
Free Microsoft Office alternative

Manage PDF Pages and Office Files with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office files. Its PDF page tools offer a visual workflow, though WPS does not run or fix Acrobat JavaScript; some PDF features may require a paid plan.

Use visual PDF page tools instead of writing an extraction scriptOpen and edit Microsoft Word, Excel, and PowerPoint formatsNavigate a familiar interface when moving from Microsoft OfficeAccess a lightweight office suite with a free version
microsoft office alternative - wps office

Frequently Asked Questions

Can Acrobat JavaScript fill in the Save As filename?

No. app.execMenuItem("SaveAs") opens the dialog, but the user must fill in its fields. To specify a filename in code, use saveAs() or the cPath option of extractPages() in a permitted context.

How do I extract more than one page?

Set nStart and nEnd in extractPages() to the first and last page indexes. For example, nStart: 0 and nEnd: 2 selects the first three pages.

Why is my programmatic save blocked?

Acrobat may restrict saveAs() or extraction to a file path in the current JavaScript context. Check the PDF permissions and use an appropriate privileged context, such as a configured trusted function.

Can I run this code in a web browser?

No. extractPages(), saveAs(), and app.execMenuItem() in these examples are Acrobat JavaScript APIs. A browser-based workflow requires a different PDF library or service.