Copy link to clipboard
Copied
Would like your kind help please, I'm trying hiding whole template pages and giving users the option to choose (By selecting Yes will unhidden pages). It works fine, but when I'm trying to implement security over the document, the function is not working.
Any otherway to do so please?
Thanks a lot
Copy link to clipboard
Copied
Show/hide a Template cannot work with Acrobat Reader, you must spawn/delete them.
It's the same for the user, but not for the document creator.
Copy link to clipboard
Copied
What JR says!!
A document script cannot use the "hidden" template property or move pages.
But a document script can use the "template.spawn()" function, and it can delete spawned pages.
Search for "Page Template" on this forum and you'll find plenty of posts on this topic.
Copy link to clipboard
Copied
How are you hiding/showing the template pages?
Adding either certificate based security or Password secrurity to a PDF does not restrict spawning and deleting template pages.
Templates also work the same for Reader as they do for Acrobat Professional. There are no restrictions.
Copy link to clipboard
Copied
Thanks @Thom Parker
I add the pages as a template and hide them and apply the following action to the tick boxe:
var hasMovedPages = false;
if (event.target.value !== "Off") {
this.getTemplate("Page2").hidden = false;
this.getTemplate("Page3").hidden = false;
this.getTemplate("Page4").hidden = false;
if (!hasMovedPages) {
this.movePage(this.numPages - 1, 4);
this.movePage(this.numPages - 1, 3);
this.movePage(this.numPages - 1, 2);
hasMovedPages = true;
}
} else {
this.getTemplate("Page2").hidden = true;
this.getTemplate("Page3").hidden = true;
this.getTemplate("Page4").hidden = true;
hasMovedPages = false; // Reset the flag if the value is "Off"
}
It work fine until I apply the restrection options showen in the attached figure. Not sure If I'm doing wrong?!
Copy link to clipboard
Copied
What JR says!!
A document script cannot use the "hidden" template property or move pages.
But a document script can use the "template.spawn()" function, and it can delete spawned pages.
Search for "Page Template" on this forum and you'll find plenty of posts on this topic.
Copy link to clipboard
Copied
Thanks @Thom Parker and @JR Boulay got the point and I used the following codeon my check box:
if(event.target.value!="Off")
{this.getTemplate("Page1" ).spawn(1, false, false);}
else
{this.deletePages(1);}
Apprecite your help of guiding me on how do I adapt this code to work on multiple pages (e.g., page 2, page 3) while maintaining the same order.
[Update] I guess the following work fine 🙂
if (event.target.value !== "Off") {
this.getTemplate("page1").spawn(1, false, false);
this.getTemplate("page2").spawn(2, false, false);
this.getTemplate("page3").spawn(3, false, false);
} else {
if (numPages > 1) {this.deletePages(1, this.numPages-1);}
}
Copy link to clipboard
Copied
Show/hide a Template cannot work with Acrobat Reader, you must spawn/delete them.
It's the same for the user, but not for the document creator.
Copy link to clipboard
Copied
"Apprecite your help of guiding me on how do I adapt this code to work on multiple pages (e.g., page 2, page 3) while maintaining the same order."
Delete all spawned pages and re-spawn the ones you need in the order you want.
A Spawned page is a duplicate of a hidden Template page so filled fields remain filled, and the user won't notice the difference.