Skip to main content
Participant
May 22, 2017
Question

duplicating a page template in a PDF form

  • May 22, 2017
  • 1 reply
  • 322 views

I've managed to find some javascript to put on a button in a PDF form that duplicates the page (after converting it into a template), but it is unlimited.

How do I set a page limit to that button.

This is the javascript I am using:

var a = this.getTemplate("PDFTemplate");

a.spawn();

I know if I add a number inside the spawn() it will duplicate and add that number of pages.

But I want it to stop adding pages after a certain amount say 3 pages and then the button stops duplicating the form.

Any ideas?

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
May 22, 2017

Let's say that after you've spawned 3 pages there are 5 pages in the file. In that case, change your code to:

if (this.numPages<5) {

     var a = this.getTemplate("PDFTemplate");

     a.spawn();

} else app.alert("You may not spawn more copies of this page.",1);

Participant
May 23, 2017

That worked perfectly!

many thanks