PDF Editing Issues

How to Extract PDF Pages with Custom Suffixes Using JavaScript

Steven ParkerSteven Parker Nov 5, 2026 869 views

Question details

The user wants to extract specific pages from a PDF and save them as separate files with custom name suffixes (e.g., _fill and _cut) using automation.

How to Extract PDF Pages with Custom Suffixes Using Acrobat JavaScript
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Automating the extraction of PDF pages and renaming them systematically using a custom JavaScript menu command.
Observed behavior
The goal is to create a custom menu tool that automatically extracts page 1 as a file with a _fill suffix and page 2 with a _cut suffix.
Before you start

Ensure you have administrative access to the Acrobat JavaScripts folder on your system, and back up your original PDF document before running custom scripts.

Solution 1Recommended

Use Acrobat JavaScript to Create a Custom Extraction Tool

Create a trusted JavaScript function to extract pages and assign custom suffixes automatically via the Acrobat Edit menu.

To perform privileged file operations like saving extracted pages directly to your local drive, you must wrap the extraction commands within a trusted function utilizing app.beginPriv() and app.endPriv().

1
Locate the JavaScripts directory

Open your system's file explorer and navigate to the Acrobat 'Javascripts' directory (this can be the program directory under Program Files or your local user AppData directory).

2
Create the script file

Create a new text document in the folder and change its extension to '.js' (e.g., ExtractWithSuffix.js). Open it with a text editor.

3
Add the trusted function code

Paste the required JavaScript code that defines the custom menu. Use 'app.addSubMenu' and 'app.addMenuItem' to create the UI buttons, and use 'this.extractPages' to specify the nStart, nEnd, and cPath for the pages.

4
Restart Acrobat

Save the .js file, close the text editor, then completely quit and restart Adobe Acrobat to load the new add-in.

5
Run the extraction tool

Open your target PDF, click on the 'Edit' menu on the top toolbar, navigate to 'Custom Tools', and select 'Extract Pages 1-2 with Suffix' to extract and save the renamed pages automatically.

Use Acrobat JavaScript to Create a Custom Extraction Tool
Script Execution: The pages will be extracted to the exact same directory as the original PDF file, with the newly applied suffixes in their file names.
Easy PDF Extraction

Extract and Manage PDF Pages Effortlessly with WPS Office

Instead of writing complex JavaScript codes, you can easily extract, split, and rename PDF pages using WPS PDF's intuitive graphical user interface.

  1. 1. Open your PDF: Launch WPS Office and open the PDF document you want to extract pages from.
  2. 2. Navigate to the Page tools: Click on the 'Page' tab located on the top ribbon to access the document management features.
  3. 3. Use the Extract feature: Click the 'Extract Page' button to open the extraction dialog box.
  4. 4. Select pages and save: Choose the specific pages you want to extract, select your desired output directory, and save them. You can easily rename the newly created files directly in your file explorer.
No coding required for extracting and splitting PDF pages.Fully compatible with standard Adobe Acrobat PDF formats.Free, lightweight, and user-friendly interface.Visual page management for quick document modifications.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my Acrobat JavaScript not extracting the pages?

File operations like extracting and saving pages require elevated privileges. Ensure your script wraps the extractPages method inside app.beginPriv() and app.endPriv() within an app.trustedFunction.

Where can I find the Acrobat JavaScripts folder?

The location varies depending on your operating system and Acrobat version. On Windows, it is typically located at C:\Program Files\Adobe\Acrobat DC\Acrobat\Javascripts or within the user's hidden AppData folder.

How do I change the specific page numbers in the script?

You can modify the nStart and nEnd parameters within the extractPages function. Keep in mind that Acrobat JavaScript uses zero-based numbering, meaning page 1 is designated as nStart: 0.