Fix Acrobat JavaScript deletePages Is Not a Function Error
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.

- 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.
Ensure you are using Adobe Acrobat Standard or Pro, as the free Adobe Reader does not support the JavaScript console or page deletion functions.
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.
Launch Adobe Acrobat and open the specific PDF file you want to modify.
Press Ctrl+J (Windows) or Cmd+J (Mac) to open the Acrobat JavaScript Console window.
Type 'this.deletePages(2, 4);' (adjusting the page index numbers as needed) and press Ctrl+Enter or keypad Enter to run the code.

Create a Folder-Level Automation Script
Add a custom menu item or toolbar button to execute the page deletion script only when a document is open.
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. Open your PDF: Launch WPS Office and open your target PDF file.
- 2. Navigate to Page management: Click on the 'Page' tab located on the top navigation toolbar.
- 3. Select pages to remove: Click on the thumbnails of the pages you want to delete.
- 4. Delete the pages: Click the 'Delete' icon (trash can) to instantly remove the selected pages from your document.

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.




