Copy link to clipboard
Copied
I have a 22 page document with 3 hidden templates. I have three different check boxes on three different pages that when checked should show or spawn the corresponding template on the page following the check box. When unchecked it should hide/delete the tempolate. What would be the script to do this?
Copy link to clipboard
Copied
Here's the entry for the template spawn method in the Acrobat JavaScript Reference:
The first parameter indicates the page where the template page will be inserted.
The page for the checkbox is "event.target.page", for a script in the checkbox MouseUp event.
Here's some sample code for the mouseUp script
if(event.target.value == "Off")
this.deletePages(event.target.page+1);
else
this.getTemplate("Name").spawn(event.target.page, false, false);
Copy link to clipboard
Copied
Just to follow up on this - I've managed to get this code to work in my document but am also looking to go to the page that is spawned. How would I achieve that?
My code is currently:
if(event.target.value == "Off")
this.deletePages(event.target.page+1);
else
this.getTemplate("Driving.HighwayCode").spawn(event.target.page+1, true, false);
Thanks.
Copy link to clipboard
Copied
Example:
Go to the first page of the document.
this.pageNum = 0;
Copy link to clipboard
Copied
The page is being spawned to "event.target.page + 1", which is the page after page where the check box is placed. So you want to set the page number to this page.
if(event.target.value == "Off")
this.deletePages(event.target.page+1);
else
{
this.getTemplate("Driving.HighwayCode").spawn(event.target.page+1, true, false);
this.pageNum = event.target.page+1;
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more