6 Replies Latest reply on Jun 10, 2016 7:25 AM by gkaiseril

    Template Spawning Duplication.


      I have created a form using Acrobat XI pro.  I spawned a template when I need to add a second, third, or fourth etc. page of my of my original form.  The second or third etc. page is only added when the previous page(s) are complete.  What is happening is that all content from all text fields are getting copied over to the additional pages.  Some of the text fields need to be copied over, where others are unique from any of the previous pages.  How do I prevent the duplication?  Thank you.


      This is the code I used to create the template


      var a = this.getTemplate("AdditionalPage");


        • 1. Re: Template Spawning Duplication.
          gkaiseril MVP & Adobe Community Professional

          Acrobat forms require unique names for all fields unless you want the form fields to have the same value.


          There are a number of optional parameters for the spawn method. One is the "bRename" parameter which forces the fields on the spawned page to be renamed. One should set this parameter to "true" and one must make sure that any existing form page does not have the same value as any field on the template.


          More information is contained in the Acrobat JavaScript API Reference for the spawn method.


          See A Lesson in Templates for Adobe Acrobat for a tutorial.


          I usually create the form with the scripts and add some coding to adjust the calculations for the renamed fields and control not to calculate on the template. Make the form a template, hide the template and then spawn a page using the template using the JavaScript console.

          • 2. Re: Template Spawning Duplication.
            steven85265304 Level 1

            Thank you!  I am very new to this.  Can you direct me where to add the bRename and how to specify which fields are renamed?

            • 3. Re: Template Spawning Duplication.
              gkaiseril MVP & Adobe Community Professional

              Links were provided to the Acrobat documentation and tutorial (the blue text).

              • 4. Re: Template Spawning Duplication.
                George_Johnson MVP & Adobe Community Professional

                Normally, you want to set the template page that you're spawning to hidden, as opposed to a visible page that the user fills in. Otherwise, even if you rename the fields when the template is spawned, the fields on the new page won't be blank.

                • 5. Re: Template Spawning Duplication.
                  steven85265304 Level 1

                  I was able to create the template and add the button to insert the template, however, I can not figure out how to prevent duplications.  I have 10 fields that I do not want to duplicate.  I have referred back to the links you provided, but I must still be doing something wrong.  Any ideas?


                  This is the javascript I used


                  var expTplt = getTemplate("Receipt - Template");


                  • 6. Re: Template Spawning Duplication.
                    gkaiseril MVP & Adobe Community Professional

                    1. Create form.
                    2. Make into template.
                    3. Make a button to spawn the new page with code like:


                    var a = this.getTemplate("AdditionalPage");
                    a.spawn({nPage: this.numPages, bRename: true, bOverlay: false});


                    3. In preview mode spawn a new page.
                    4. Return to the Edit mode and using the forms panel, sort the field names alphabetically, select the "P1" field and rename to "P0". This will rename all the children fields under "P1" TO "P0".
                    5. Hide the template.
                    6. Exit the Prepare Form tool.

                    7. Save the form.