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

Spawning Pages and Template Help

New Here ,
Jan 03, 2025 Jan 03, 2025

I have reviewed multiple document and websites trying to learn how to properly spawn 1 or more pages in a PDF document. All of these references I've found indicate there is a template, but none of them discuss how the termplate is created or used. Inside my PDF are two forms with fields which need to be duplicated 1 or more times. The first one is a single page, the other is a 2-page form. Both of these need to have the capability to spawned with the renaming of the fields.

 

Questions:

1. How and where is a template created from an existing PDF page(s)?

2. Are templates embedded in the PDF or are they separate files?

3. What would be the proper way to spawn a single page form as the next page in the PDF document?

4. What would be the proper way to spawn a 2-page form as the last pages of the PDF document?

 

Any help here would be greatly appreciated. Thanks.

TOPICS
How to , JavaScript , PDF forms
1.8K
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 ,
Jan 03, 2025 Jan 03, 2025

Don't use this.newPage which creates a new page.  The spawn method creates the new page.  this.spawnPageFromTemplate was replace by the spawn method.  Use this:

this.getTemplate("ScopeOfWork").spawn({bRname:true});

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 ,
Jan 03, 2025 Jan 03, 2025

1.  You can convert a page into a template with a script by running the following script in the console where "MyTemplate" is the name of the template and 0 is the 0-based page index:

this.createTemplate("MyTemplate",0);

 or you can search Template in the Acrobat tools and while on the page you want to convert, select Templates > Convert current page to template, then name it in the popup dialog. 

2.  They aren't separate files, they are pages that have been converted to templates.

3.  https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/doc.html#spawnpagefromtemplate

4.  You have to spawn 2 different templates (one for each page).

Here's a couple of articles on template spawning (with video):

https://pdfautomationstation.substack.com/p/check-boxes-that-show-and-hide-pdf

https://pdfautomationstation.substack.com/p/buttons-that-add-and-delete-pdf-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 ,
Jan 03, 2025 Jan 03, 2025

I was able to create the template pages via the console (all 3). I can see them when I use the "organize" tool. I am using the following code and nothing happens to create the new page.

 

var tempName = "ScopeOfWork";
var currPage = this.pageNum;
this.newPage(currPage+1);
this.spawnPageFromTemplate(tempName,currPage+1,true);

Any ideas why this doesn't work?

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 ,
Jan 03, 2025 Jan 03, 2025

Don't use this.newPage which creates a new page.  The spawn method creates the new page.  this.spawnPageFromTemplate was replace by the spawn method.  Use this:

this.getTemplate("ScopeOfWork").spawn({bRname:true});

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 ,
Jan 03, 2025 Jan 03, 2025
LATEST

That did the trick. I had to add in the "bOverlay:false" option becaue it wrote over the next page. 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
Community Expert ,
Jan 03, 2025 Jan 03, 2025

1. Bild1.jpg

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