Skip to main content
Known Participant
April 2, 2020
Answered

Remove & Spawned Pages

  • April 2, 2020
  • 3 replies
  • 3925 views

I have a 2 page form with buttons. 2 of the buttons have the ability to spawn a new page when selected. If both of these buttons are selected then the form go from the initial 2 pages to a total of 4. My question is that I have a clear form button that when pressed I want any and all spawned pages remove to reset the form to the original 2 pages. When I enter the script below it will remove one of the 2 pages, but not both. What am I missing?

 

if (numPages > 2) {

this.deletePages(2, this.numPages-2);

}

This topic has been closed for replies.
Correct answer JR Boulay

Your script only deletes the third page.

 

if (numPages > 2) {this.deletePages(2, this.numPages-1);}

 

See : https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/index.html#t=Acro12_MasterBook%2FJS_API_AcroJS%2FDoc_properties.htm%23TOC_numPagesbc-34&rhtocid=_6_1_8_23_0_33

3 replies

Known Participant
April 3, 2020

Ok so I have another question that pertains to the spawn and delete pages. Is there a way to spawn a certain number of additional pages from a selection in a drop down, that could be activated by a button selection. Here's what I am dealing with. I am making a form for quoting construction work. One of the options is to write a quote for multiple trips to the site. If the quote is for multiple trips, then I want to be able to add additional pages for each trip. 95% of our work is done in one trip, but we do have jobs where it can take up to 15 trip. So if I select the YES button for multiple trips, I can get it to spawn the additonal page, but is there a way for the Yes button to activate a drop down and whatever number is selected, than that many additonal pages would spawn to increase the length of the form.

 

I am in my infancy in learning scripts, so any help would be greatly appreciated.

Inspiring
April 4, 2020

J

Have a look at this PDF in the action of the button Add

https://documentcloud.adobe.com/link/review?uri=urn%3Aaaid%3Ascds%3AUS%3Ab11673e1-f9fc-4e3d-b1b8-eb5066c71392

 

With the following code you will create a template from the first page.  

this.createTemplate({cName:"AgentSetup", nPage:0 });

 You can then view the templates in the tool Organize pages the templates…

JR Boulay
Community Expert
Community Expert
April 3, 2020

Extended Rights is no longer required since the release of Acrobat Reader XI (11), eight years ago (2012).

 

Older versions of Reader requires Extended Rights for Commenting and form filling, but they doesn't support spawning.

Acrobate du PDF, InDesigner et Photoshopographe
Inspiring
April 4, 2020

But why can't I then save the form with another name in Acrobat Reader?

JR Boulay
Community Expert
Community Expert
April 4, 2020

Nnormally you can "Save as" with all versions of Reader, whether PDF is activated or not.
The issue comes from elsewhere…

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
April 2, 2020
Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
April 2, 2020

Thanks JR, that worked like a charm. Stay safe.