Skip to main content
Participant
June 16, 2019
Answered

Using button in combination with drop down box?

  • June 16, 2019
  • 1 reply
  • 681 views

Hello everyone, I am new to using Acrobat. I have ten (10) pages named page 1 through page 10. I'd like to have page 1 have a drop down box and a button. The drop down box would have number 1-5.

A default selection in drop down box would be 1. The default setup for the PDF would be pages 1-4. I would like it if the user selects number 2 from drop down box, then I would like page 5 added to PDF. If user selects value 2 from drop down box then page 6 would be added to PDF.If user selects value 3 from drop down box, then I would like page 7 added.

To be clear...the default setup would be pages 1-4 visible. Pages 6-10 as non-visible. Then depending on selection an additional page (from page 5 to 10) would be added to PDF.

Also I would like after user picks number 1-5 from drop down box that the user has to press the button to actual have the above action to happen.

And if possible I would like a selection to delete or hide a selection made an error. Like if they wanted to select value number 2 from drop down box but selected number 5 in error.

Could someone walk me through this process?

This topic has been closed for replies.
Correct answer try67

To do that you would need to define those pages as Templates, hide them, and then spawn pages from them or make them visible again, depending on how the file is going to be used. If it's going to be used in Reader you have to spawn pages; If it will only be used in Acrobat then you can simply make them visible. Either way, it will require using a script.

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 16, 2019

To do that you would need to define those pages as Templates, hide them, and then spawn pages from them or make them visible again, depending on how the file is going to be used. If it's going to be used in Reader you have to spawn pages; If it will only be used in Acrobat then you can simply make them visible. Either way, it will require using a script.

geediazjrAuthor
Participant
June 16, 2019

I can spawn a page using the below code. What would I need to add?

this.getTemplate("2") .spawn ({nPage: this.numPages, bRename: false, bOverylay: false});

I am using Adobe Acrobat Pro.

Would using a CLEAR button erase the added pages? How do I get the spawn button to select certain pages depending on the drop down box selection?

try67
Community Expert
Community Expert
June 16, 2019

You can use an if-condition, like this:

if (event.value=="2") this.getTemplate("2") .spawn ({nPage: this.numPages, bRename: false, bOverylay: false});

if (event.value=="3") {

     this.getTemplate("2") .spawn ({nPage: this.numPages, bRename: false, bOverylay: false});

     this.getTemplate("3") .spawn ({nPage: this.numPages, bRename: false, bOverylay: false});

}

etc.

This code should be used as the custom validation script of your drop-down.

And no, the Clear (or resetForm, if done using a script) command does not delete spawned pages.

You will need to use the deletePages command for that. For example:

if (this.numPages>4) this.deletePages(4, this.numPages-1);