• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Spawn templates after a specific page with checkboxes

New Here ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

I have 3 checkboxes named (NYC, NY and NJ) that spawn a template (all 3 are different templates) when checked and hides it when unchecked, but I need it to show a specific page not at the end, what am I missing? (im not a coder)

 

if(event.target.value!="Off")
{this.getTemplate("NYC" ).hidden=false;}
else
{this.getTemplate("NYC" ).hidden=true;}

TOPICS
Create PDFs , General troubleshooting , How to , JavaScript , PDF forms

Views

527

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 01, 2023 Feb 01, 2023

The code I provided needs to be put into the original code that uses the check state to determine whether the template is spawned or deleted. 

if(event.target.value!="Off")
{this.getTemplate("NYC" ).spawn(nTargetPageNumber, false, false);}
else
{this.deletePages(nTargetPageNumber);}

 

The trick for removing the page is to determine the actual page number. This is simple if nothing has changed since the template was spawned, but if other templates were spawned, then you'll need some way to find t

...

Votes

Translate

Translate
Community Expert ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

You can spawn template pages where you want.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

I can move it yes manually, but when i click on the checkbox it re spawns at the end of the form

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

The code you've shown does not "spawn" the page template. It hides and shows the actual template, which will always be placed at the end of the document. This will not work in the free Reader. To make the page appear at the desired location it has to be "spawned". 

 

this.getTemplate("NYC" ).spawn(nTargetPageNumber, false, false);

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

Thank for you this very helpful. Now if I uncheck the box it "spawns" again is that supposed to be?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

The code I provided needs to be put into the original code that uses the check state to determine whether the template is spawned or deleted. 

if(event.target.value!="Off")
{this.getTemplate("NYC" ).spawn(nTargetPageNumber, false, false);}
else
{this.deletePages(nTargetPageNumber);}

 

The trick for removing the page is to determine the actual page number. This is simple if nothing has changed since the template was spawned, but if other templates were spawned, then you'll need some way to find the page. The best technique is to have a field with a unique name on the page. 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 01, 2023 Feb 01, 2023

Copy link to clipboard

Copied

LATEST

Thank you very much Thom, it worked perfectly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines