Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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});
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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});
Copy link to clipboard
Copied
That did the trick. I had to add in the "bOverlay:false" option becaue it wrote over the next page. Thanks!
Copy link to clipboard
Copied
1.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more