Skip to main content
Participant
July 27, 2022
Question

Deleting all pages in a pdf file after a page with a specific text

  • July 27, 2022
  • 1 reply
  • 478 views

Hello, I am a complete beginner with javascript and need help with creating a script in Acrobat DC. Maybe someone can help me 🙂

I have several 1,000 pdf documents with varying numbers of pages. However, all documents contain a specific text that only appears once in the document, but on a different page in each document.

I would like to use a script to find the page with the specific text and then delete all pages after this page.

 

Example:
Total number of pages: 125
Specific text: "Document attachment"
Number of pages with specific text: 27

 

Task:
Delete pages 28 to 125

 

It would be great if someone could help me with a script that does this task.

Many thanks in advance

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
July 27, 2022

The best way to do that is in an Action. You can use the Search & Remove text command to locate the text and mark it for redaction. Then you use a script to locate those Redaction comments and delete the pages they are on. The latter has to be done from the last page backwards, though.