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

duplicating a page template in a PDF form

New Here ,
May 22, 2017 May 22, 2017

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?

TOPICS
Acrobat SDK and JavaScript
280
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 ,
May 22, 2017 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);

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 ,
May 23, 2017 May 23, 2017
LATEST

That worked perfectly!

many thanks

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