Making buttons to add and REMOVE optional pages of a form
Copy link to clipboard
Copied
I am creating a form that has some pages which are optional based on user's needs. I've figured out how to place buttons that will spawn those additional pages based on embedded templates; however, I also want to have buttons that will hide said pages again in case someone adds one in error. The script I used in the buttons to add the pages is this:
var a = this.getTemplate ("Interview notes");
a.spawn();
I tried using this script in a "Remove Page" button...
Copy link to clipboard
Copied
As you've seen. A field script in Reader can delete, but not hide a template page. So the correct method for using a page template is to always hide the template up front (at design time). If a template page is needed in the initial document, then it should also be spawned up front. Then a script can be used to delete it.
Again, the correct method for using a page template is to spawn and delete pages from the original template, which is hidden.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
So, no way to re-hide it after it has spawned?
Copy link to clipboard
Copied
No, Template pages are spawned and deleted. Never hidden. The hidden attribute for the template is a convience for form design. It is not used at runtime.
Use the Acrobat JavaScript Reference early and often

