Skip to main content
Fiddling Orion
Inspiring
December 20, 2022
Answered

Duplicate pages but change auto text fields name

  • December 20, 2022
  • 3 replies
  • 1566 views

Hello, I tried and now I need help with an application I am building...

 

I have a button that can produce spawned hidden page tenplates via the Javascript action, but when I do with the same feature on the same hidden page, it retains the field names and data. Is there a way to produce the same hidden pages multiple times, but automatically changed the field data names in the new page so copied data doesn't duplicate?

 

Or must I create a duplicate template for each possible click and change the names myself?

 

Or is there a way to duplicate the page directly without merging the field names (thus, creating new field data).

 

Here is the code I use for the spawning of the hidden template:

 

var a = this.getTemplate("EmploymentPage");
a.spawn(this.pageNum+1,true,false);
this.calculateNow();

 

Just trying to save some time here. 

Thanks in advance 🙂

This topic has been closed for replies.
Correct answer JR Boulay

You must use the bRename method (set to true):

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#template

3 replies

JR Boulay
JR BoulayCorrect answer
Community Expert
December 21, 2022
Acrobate du PDF, InDesigner et Photoshopographe
Fiddling Orion
Inspiring
December 21, 2022

Thanks, after much trial and error (kind of new to Javascript), I got it right. 

Here is what I did, 

var a = this.getTemplate("EmploymentPage");
a.spawn({nPage:this.pageNum+1, bRename:true, bOverlay:false});
this.calculateNow();

Works beautifully!

Bernd Alheit
Community Expert
December 21, 2022

You can avoid this when you spawn the page at the end of the document:

a.spawn(this.numPages,true,false);

 

Or spawn the page after already spawned pages.

Fiddling Orion
Inspiring
December 21, 2022

Sadly, the spawned pages have to be in the middle of the application (which there are three instances where that happens for three different pages). But that's good to know. Thanks!

 

Nesa Nurani
Community Expert
December 21, 2022

Rename is set to true in your script, so it should rename fields. Can you share your file with us?

Fiddling Orion
Inspiring
December 21, 2022

I have to get permission from our corporate management, but will do if can unless I have a solution sooner. 

Thanks!