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

Hide and unhide a page / template js

New Here ,
Jul 17, 2024 Jul 17, 2024

Good afternoon,  

 

I currently use Adobe Acrobat Pro, and in one of the drop down fields under format, custom keystroke, I am using the following code:

this.getTemplate("Temp 1").hidden = true;
if (event.willCommit)
{
switch(event.value)
{

case "2":
this.getTemplate("Temp 1").hidden = false;
break;

Temp 1 is basically a page out of 30 pages that we have converted to a template (under organize pages, selected the page and select page templates and gave it the name).

when the code above is run, temp 1 is appearing as the last page. I tried a lot of approaches to try to make it appear as page #4 and nothing seems to be working. I tried different AI to get the right code but I am pretty sure I am missing several steps. 

What is the best approach to make this page appear under page 4 when option 2 is selected from the drop down, while making sure its hidden again when I go back to option 1.

 

thank you.

TOPICS
JavaScript
641
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Jul 18, 2024 Jul 18, 2024
LATEST

 

If your file have 30 pages when you spawn template, you can try this as validate script of dropdown field, it will spawn template as fourth page and delete that page if dropdown is not 2 and number of pages are 30:

var t1 = this.getTemplate("Temp 1");
if (event.value == "2"){
t1.spawn({nPage: 3, bRename: false, bOverlay: false});}
else if(event.value != "2" && this.numPages == 30) 
this.deletePages(3);

View solution in original post

Translate
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 ,
Jul 18, 2024 Jul 18, 2024

Before answering your question: Is this file supposed to be used in Reader, or only in Acrobat? Because the hidden property can't be set in the former...

Translate
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 ,
Jul 18, 2024 Jul 18, 2024
LATEST

 

If your file have 30 pages when you spawn template, you can try this as validate script of dropdown field, it will spawn template as fourth page and delete that page if dropdown is not 2 and number of pages are 30:

var t1 = this.getTemplate("Temp 1");
if (event.value == "2"){
t1.spawn({nPage: 3, bRename: false, bOverlay: false});}
else if(event.value != "2" && this.numPages == 30) 
this.deletePages(3);
Translate
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