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

Duplicate pages but change auto text fields name

Explorer ,
Dec 20, 2022 Dec 20, 2022

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 🙂

TOPICS
Create PDFs , JavaScript , PDF forms
1.4K
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 ,
Dec 21, 2022 Dec 21, 2022

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

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


Acrobate du PDF, InDesigner et Photoshopographe

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 ,
Dec 20, 2022 Dec 20, 2022

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

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
Explorer ,
Dec 21, 2022 Dec 21, 2022

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

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
Explorer ,
Dec 21, 2022 Dec 21, 2022
LATEST

I got it worked out (see my response to correct answer) so no need to share file. 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 ,
Dec 21, 2022 Dec 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.

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
Explorer ,
Dec 21, 2022 Dec 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!

 

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 ,
Dec 21, 2022 Dec 21, 2022

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

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


Acrobate du PDF, InDesigner et Photoshopographe
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
Explorer ,
Dec 21, 2022 Dec 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!

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