Skip to main content
Known Participant
December 13, 2016
Answered

undo spawned page in Reader DC

  • December 13, 2016
  • 2 replies
  • 1253 views

I found this photo album in the forums and have been playing around with it. This question arises from trying to view it using the Reader DC. The album works fine up to a point. And that point is, not being able to delete the page if I need to delete it. Viewing it in Acrobat Pro X, I'm able to delete the pages I choose. Is it possible to delete page(s) in Reader DC or undo the spawned page? I've been searching through the forums and only found some info telling me that Reader can undo a page which has been spawned, but not how to do it with javascript.

Can someone throw the dog a bone and tell me how to do it? A little example would be a big help. Thanks guys.

This topic has been closed for replies.
Correct answer George_Johnson

It wasn't meant to be a script, but rather the name of the method you need to use. The Acrobat JavaScript reference documentation will show how it's used, particularly the start and stop page numbers. You'll need to be able to keep track of which pages were created by spawning a template. This can either be very simple or more complicated depending on how you've set things up. For example, if you begin with a single page PDF and it now has two pages (doc.numPages == 2), and you've set up the code to create a new page at the end of the document, you can delete the page with the following:

// Delete the last page of the document

deletePages({nStart: numPages - 1});

You can find the documentation in the freely available Acrobat SDK or by doing a search for "Acrobat JavaScript Reference".


Also, if you want to use a button on a page to delete it, you can use the following as the Mouse Up script of the button:

// Delete this page

deletePages({nStart: event.target.page});

2 replies

JR Boulay
Community Expert
Community Expert
December 13, 2016

Hi.

- Reader can delete spawned pages only. (vs Acrobat Pro/Sta).

- Spawning/deleting pages requires Reader XI or DC, this is not supported in older versions (but it works in any Acrobat Pro/Sta version).

- The PDF must NOT be Reader-Extended: this prevent spawning to works in Reader XI and DC.

Acrobate du PDF, InDesigner et Photoshopographe
pdfUser1Author
Known Participant
December 13, 2016

I have followed you guys for what seems like years now, on the AcrobatUsers forum and both of you (and many others) have helped me by giving of your time. You all have been very generous with it. I thank all you guys for the lessons I've learned. I truly enjoy working with javascript and discovering new capabilities of using it with PDFs.

JR Boulay
Community Expert
Community Expert
May 26, 2017

Acrobate du PDF, InDesigner et Photoshopographe
Inspiring
December 13, 2016

You can use the doc.deletePages method to delete a page that was created by spawning a template.

pdfUser1Author
Known Participant
December 13, 2016

Thanks for the quick response, George. I tried the bit of script you provided. I created a button and attached doc.deletePages to mouseUp action but nothing happened in Acrobat Pro X. I saved the doc then tried to open it in Reader DC, still nothing. Forgive my lack javascripting knowledge, I'm trying to learn. I just don't understand. That's why I ask for examples. Sometimes someone will provide the help, sometimes not.

Inspiring
December 13, 2016

It wasn't meant to be a script, but rather the name of the method you need to use. The Acrobat JavaScript reference documentation will show how it's used, particularly the start and stop page numbers. You'll need to be able to keep track of which pages were created by spawning a template. This can either be very simple or more complicated depending on how you've set things up. For example, if you begin with a single page PDF and it now has two pages (doc.numPages == 2), and you've set up the code to create a new page at the end of the document, you can delete the page with the following:

// Delete the last page of the document

deletePages({nStart: numPages - 1});

You can find the documentation in the freely available Acrobat SDK or by doing a search for "Acrobat JavaScript Reference".