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

Enable javascript for Adobe reader

New Here ,
Nov 06, 2022 Nov 06, 2022

I´m trying to create a PDF with a javascript showing different pages (templates) based on a selection in a dropdown list. This works perfectly fine in my Adobe Acrobat Standard (32-bit) but most of the persons that will use the PDF have Adobe Reader (64-bit), but even though they enable javascript in Prefereces, the javascript does not work (i.e., showing only already visible pages (templates)). 
Please let me know if I can do someting to make this work?

TOPICS
Create PDFs , How to , JavaScript , PDF forms
1.5K
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 ,
Nov 07, 2022 Nov 07, 2022

To spawn a page as the last page of the file:

this.getTemplate("Template1").spawn(this.numPages-1, false, false);

To delete the last page of the file:

this.deletePages(this.numPages-1,this.numPages-1);

You should really read the documentation of these methods, though, to know what all the parameters mean.

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 ,
Nov 06, 2022 Nov 06, 2022

What script does you use?

Does you spawn template pages?

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
New Here ,
Nov 06, 2022 Nov 06, 2022

This is the script (not spawning templates) which works perfectly fine in Adobe Standard: 

this.getTemplate("page 9 P&ID Compact" ).hidden = true;
this.getTemplate("page 10 P&ID CF" ).hidden = true;
this.getTemplate("page 11 P&ID Std" ).hidden = true;
this.getTemplate("page 12 3D Compact" ).hidden = true;
this.getTemplate("page 13 3D CF" ).hidden = true;
this.getTemplate("page 14 3D CF" ).hidden = true;
this.getTemplate("page 15 3D Std" ).hidden = true;
this.getTemplate("page 16 3D Std" ).hidden = true;

if(event.value=="3.2 Compact")
{
this.getTemplate("page 9 P&ID Compact").hidden=false;
this.getTemplate("page 12 3D Compact" ).hidden=false;
}

if(event.value=="3.2 Compact Flex")
{
this.getTemplate("page 10 P&ID CF").hidden=false;;
this.getTemplate("page 13 3D CF").hidden=false;;
this.getTemplate("page 14 3D CF").hidden=false;;
}

if(event.value=="3.2 Standard")
{
this.getTemplate("page 11 P&ID Std" ).hidden=false;;
this.getTemplate("page 15 3D Std").hidden=false;
this.getTemplate("page 16 3D Std").hidden=false;;
}

 

 

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 ,
Nov 07, 2022 Nov 07, 2022

The hidden property of a Template object can't be changed in Reader, only in Acrobat.

If you want to show/hide pages in Reader you must spawn a copy of the Template and then delete that page (using the deletePages method of the Doc object) when you wish to hide it.

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
New Here ,
Nov 07, 2022 Nov 07, 2022

Thank you. 
Can you give me one example of how that script could look like? For example to spawn and delete one template? 

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 ,
Nov 07, 2022 Nov 07, 2022

To spawn a page as the last page of the file:

this.getTemplate("Template1").spawn(this.numPages-1, false, false);

To delete the last page of the file:

this.deletePages(this.numPages-1,this.numPages-1);

You should really read the documentation of these methods, though, to know what all the parameters mean.

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
New Here ,
Nov 07, 2022 Nov 07, 2022
LATEST

Thank you so much! 

Will continue with reading and trial and error. 

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