PDF Editing Issues

Fix Acrobat JavaScript deletePages Is Not a Function Error

Steve KSteve K Nov 3, 2026 869 views

Question details

The user is trying to automate PDF page deletion using a JavaScript startup script in Adobe Acrobat, but encounters a 'deletePages is not a function' error.

How to Fix Acrobat JavaScript deletePages Is Not a Function Error
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Running a custom JavaScript automation script in the Acrobat startup folder to delete specific pages from a PDF.
Observed behavior
The script fails upon execution because startup scripts run before any PDF file is actually open, rendering the document-specific 'this.deletePages' command invalid.
Before you start

Ensure you are using Adobe Acrobat Standard or Pro, as the free Adobe Reader does not support the JavaScript console or page deletion functions.

Solution 1Recommended

Use the Acrobat JavaScript Console

Execute the deletePages command manually through the JavaScript debugger while the target document is open.

Since the 'this.deletePages' method requires an active document context, running it directly in the console bypasses the startup script limitation.

1
Open your PDF document

Launch Adobe Acrobat and open the specific PDF file you want to modify.

2
Access the JavaScript Debugger

Press Ctrl+J (Windows) or Cmd+J (Mac) to open the Acrobat JavaScript Console window.

3
Execute the deletion command

Type 'this.deletePages(2, 4);' (adjusting the page index numbers as needed) and press Ctrl+Enter or keypad Enter to run the code.

Use the Acrobat JavaScript Console
Page Indexing: Keep in mind that JavaScript in Acrobat uses zero-based indexing. Page 1 of the PDF is index 0.
Manage PDF Pages Easily

Easily Delete PDF Pages with WPS Office

Skip the complex JavaScript coding and folder-level automation. WPS Office provides an intuitive, visual interface to delete, reorder, and manage PDF pages in just a few clicks.

  1. 1. Open your PDF: Launch WPS Office and open your target PDF file.
  2. 2. Navigate to Page management: Click on the 'Page' tab located on the top navigation toolbar.
  3. 3. Select pages to remove: Click on the thumbnails of the pages you want to delete.
  4. 4. Delete the pages: Click the 'Delete' icon (trash can) to instantly remove the selected pages from your document.
No coding or JavaScript debugging requiredVisual page management interface for quick editsFully compatible with Microsoft Office formats and standard PDFsLightweight, fast, and free to download
microsoft office alternative - wps office

Frequently Asked Questions

Why does this.deletePages work in the console but not in a startup script?

Startup scripts are executed when Adobe Acrobat launches, before any PDF documents are opened. The 'this' object refers to the active document, which doesn't exist yet during startup, causing the function to fail.

Can I run a JavaScript on a PDF just by double-clicking the file?

No, Acrobat does not support running a startup script automatically on a file just by opening it from your operating system. You must trigger the script via a custom menu button, the console, or a document-level action.

Does Adobe Acrobat Reader support the deletePages function?

No, the deletePages method requires Adobe Acrobat Standard or Pro. Adobe Reader does not have the permissions to delete pages, even if you try to execute it via JavaScript.