Skip to main content
New Participant
July 16, 2020
Answered

Trying to create a button to delete pages in a PDF

  • July 16, 2020
  • 1 reply
  • 13330 views

Hi there! I'm not super familiar with interactive PDFs - It's been a while. 😉

 

I'm working on a doc that I would like to have buttons that would delete sections (multiplate pages) of the document. Essentially it's a collection of forms and we don't always need all of them. So I'm looking for a quick way to hit a button to remove them from the collection. 

 

Do I do that through Javascript? If so, how do I do that? Thank you!!! 

This topic has been closed for replies.
Correct answer Amal.

Hi there

 

Please use the script this.deletePages(0,3); from the first link shared esarlier and see if that works for you.
Note you can change the page range in the scrpit as per your requirement.

 

Regards

Amal

1 reply

Amal.
Community Manager
Community Manager
July 16, 2020

Hi Codyc

 

We are sorry for the trouble. As described you want to create a button to delete some pages from the PDF form.

 

Would you mind sharing if you have Adobe Acrobat Reader DC  (Freeware Application) or Adobe Acrobat DC (Subscription)?

You may please refer to the similar discussions below and see if that works for you.

 

1. Solved: button to delete pages - Adobe Support Community - 9084910

2. https://acrobatusers.com/forum/forms-acrobat/using-button-delete-pages/ 
Note: The scripts would not work with Adobe Acrobat Reader DC

 

Hope it will help

 

Regards

Amal

New Participant
July 16, 2020

Hi Amal! 

 

Thanks for the reply! I have the full version of Acrobat and the latest creative cloud subscription. 

 

I've attached a screenshot to show you what I mean - I think this is where I'd put the javascript but I'm not sure what script to copy/paste and how/where I would reference what pages I wanted deleted?

try67
Community Expert
July 16, 2020

This is great Amal! I put it in and it worked - what I'm struggling with is the page range, 0,3 

If I have prefixes on my page numbers (example a1, b1, b2) how do I enter those into the script properly? 

Thanks so much for your help!


You don't. The script uses physical page numbers only (thankfully), not page labels. And those numbers are 0-based, so 0 means the first page in the file, and 3 means the fourth page. If you want to refer to the last page in the file you can do so using this.numPages-1 .