20 Replies Latest reply on Dec 15, 2010 2:15 PM by gkaiseril

    Carbon Copy Adobe Acrobat Form

    JoshStout

      I have a client who wants to carbon copy fillable Acrobat forms.  I have succeeded in duplicating the form pages (script below), however the form objects contain the same name so when I enter data on Field1, Page1 it propagates through Field1 on *all* pages. 

       

      Two ideas: Rename the objects on each page during the during the duplication process.  -- OR -- rename the objects with a reference to the page number on initialization.


      Any ideas out there?

       

      Josh


      // Carbon Copy pages in the PDF file

      // IMPORTANT: Set Output Options to the filename you need


      // CHANGE THIS NUMBER: IT'S NUMBER OF ADDITIONAL COPIES

      var nNumCopies = 2; // make 1 additional copy(es) of each page


      try {


      var newName = this.path;

      var filename = newName.replace(".pdf","_Original.pdf"); // save a copy of original document

      this.saveAs(filename);


      var Num = this.numPages;

      var nNumDups = nNumCopies+1;


      for (var i = 0; i < Num; i++) {

          for (var j = 0; j < nNumCopies; j++) {

              k = i*nNumDups + j;

              this.insertPages({ nPage: k, cPath:newName, nStart:i });

              }

          }


      // set page labels: number each copy with a label

      for (var k = 0; k < this.numPages; k+= nNumDups)

      {

           this.setPageLabels(k,[ "D", "Copy ", 1]);  

      }


      }

      catch(e)

      {

          app.alert(e);

      }

        • 1. Re: Carbon Copy Adobe Acrobat Form
          try67 MVP & Adobe Community Professional

          Better yet: Create a Template from the pages you want to duplicate and then use the spawn method to create carbon-copies of them.

          One of the parameters of this method allows you to automatically rename all the form fields.

          For more info look in the reference under the Template object, and the Document object's createTemplate method.

          • 2. Re: Carbon Copy Adobe Acrobat Form
            JoshStout Level 1

            I built the form as a template (.tds).  I then built a batch processing Javascript

             

            var a = this.templates;

            for (i = 0; i < a.length; i++)

            {a[i].spawn(this.numPages, false, false)};

             

            This didn't work.

             

            So I tried to create the template objects with this:

             

            this.createTemplate({cName: "myTemplate1.pdf", nPage: 1});

             

            No luck either.  There there is no logging, console, IDE, etc. I have no way to troubleshoot what I'm doing wrong.

             

            Any help would be great.

            • 3. Re: Carbon Copy Adobe Acrobat Form
              try67 MVP & Adobe Community Professional

              There is a console, and it contains any error messages that might occur. You

              can open it with Ctrl+J.

              You can also use it to run code.

              • 4. Re: Carbon Copy Adobe Acrobat Form
                JoshStout Level 1

                Any idea why my code isn't spawning the form pages?  The code is straight

                out of the docs.

                • 5. Re: Carbon Copy Adobe Acrobat Form
                  try67 MVP & Adobe Community Professional

                  You need to first create the template, and then spawn it. Doing just one of

                  these steps, or doing them in the wrong order, won't work.

                  • 6. Re: Carbon Copy Adobe Acrobat Form
                    JoshStout Level 1

                    I created the template as a .tds  Unfortunately, I am not permitted to

                    select a .tds file when I am spawning.   So I took my PDF and executed

                    this.createTemplate.

                     

                    this.createTemplate();

                     

                    Nothing happened.

                     

                    I tried with page 0

                     

                    this.createTemplate();

                     

                    Nothing.  No errors.  No files created.  No output.  No feedback.  Just

                    nothing.

                    • 7. Re: Carbon Copy Adobe Acrobat Form
                      JoshStout Level 1

                      Javacript console won't permit me to execute code.  I have a green dot (no

                      idea what that is for).  A red X which kills the window.  And a Goto Line

                      number button.

                      • 8. Re: Carbon Copy Adobe Acrobat Form
                        try67 MVP & Adobe Community Professional

                        I don't know what you mean by a .tds file. A javascript template is not a

                        separate file, it's a part of the PDF.

                        To run code from the console you need to select it with the mouse and press

                        the Enter key at the bottom right of the keyboard.

                        • 9. Re: Carbon Copy Adobe Acrobat Form
                          JoshStout Level 1

                          Console displayed the error: NotAllowedError: Security settings prevent

                          access to this property or method.

                           

                          this.createTemplate();

                           

                          NotAllowedError: Security settings prevent access to this property or

                          method.

                          Doc.createTemplate:2:Batch undefined:Exec

                          • 10. Re: Carbon Copy Adobe Acrobat Form
                            try67 MVP & Adobe Community Professional

                            This method can only be used in batch, console or menu events, as is

                            mentioned in the reference files.

                            From where are you running this code?

                            • 11. Re: Carbon Copy Adobe Acrobat Form
                              JoshStout Level 1

                              I created a batch job: TOOLS > DOCUMENT PROCESSING > BATCH PROCESSING >

                              EXECUTE JAVASCRIPT SEQUENCE.

                               

                              I can't execute code from the console.  There is no enter key on the bottom

                              right of my laptop keyboard.  When I paste the code there is no way to

                              execute it.

                              • 12. Re: Carbon Copy Adobe Acrobat Form
                                JoshStout Level 1

                                this.createTemplate();

                                 

                                NotAllowedError: Security settings prevent access to this property or

                                method.

                                Doc.createTemplate:2:Batch undefined:Exec

                                 

                                topmostSubform.Page1.Review has no properties

                                • 13. Re: Carbon Copy Adobe Acrobat Form
                                  try67 MVP & Adobe Community Professional

                                  From the last line it seems to me like you're trying to run this on a form

                                  created in LiveCycle, which might not be possible.

                                  You should post your question on the LC Designer forum, if that's the case.

                                  • 14. Re: Carbon Copy Adobe Acrobat Form
                                    JoshStout Level 1

                                    CTRL-ENTER allows me to execute code in the console.

                                    • 15. Re: Carbon Copy Adobe Acrobat Form
                                      JoshStout Level 1

                                      Ran code from CONSOLE with this result:

                                       

                                      this.createTemplate();

                                      NotAllowedError: Security settings prevent access to this property or

                                      method.

                                      Doc.createTemplate:1:Console undefined:Exec

                                       

                                      undefined

                                      • 16. Re: Carbon Copy Adobe Acrobat Form
                                        JoshStout Level 1

                                        Please send link to LC Designer forum.

                                         

                                        Yes, it's on a LiveCycle form.

                                        • 17. Re: Carbon Copy Adobe Acrobat Form
                                          klwalsh611

                                          try67 -- "Create a Template from the pages you want to duplicate and then use the spawn method to create carbon-copies of them.

                                          One of the parameters of this method allows you to automatically rename all the form fields.

                                          For more info look in the reference under the Template object, and the Document object's createTemplate method"

                                           

                                          I have a pdf order form that has two addtl pages that are each set up to be templates that will spawn to the first page of the document depending upon a selection made via a radio button.

                                           

                                          I tested the functionality within Acrobat Pro 9 Extended and it worked as anticipated. Yea!

                                          I then chose the Advanced feature "Extend Features in Reader" so that my end users can fill out the form and either print/fax or email it back to me. Now the spawning doesn't function and the JS console displays an error message: "NotAllowedError: Security settings prevent access to this property or method.
                                          Template.spawn:10:Field rbuCustType:Mouse Up".

                                           

                                          After some internet research I have sadly concluded that the spawn template won't work in documents that are "extended for Reader". Is that true and if so, how do I get around this?

                                           

                                          The two addlt pages have different fields for order total and shipping information based upon a domestic or international customer type. How else can I have the appropriate information appear on the first page? Would using the .hidden property for each field be the solution?

                                           

                                          Thanks in advance!

                                          • 18. Re: Carbon Copy Adobe Acrobat Form
                                            try67 MVP & Adobe Community Professional

                                            To remove the extended reader rights save a copy of the file using File -

                                            Save Copy As... Then you can spawn new pages.

                                            In Reader it's not possible at all to use the spawn command (well, it is,

                                            but it costs thousands of dollars to buy the software that allows it).

                                             

                                            Not sure I understand your last question.

                                            • 19. Re: Carbon Copy Adobe Acrobat Form
                                              klwalsh611 Level 1

                                              I need the extended reader rights in place because the target audience uses the free reader software - not the $$ acrobat product so spawning won't be an option. I was able to consolidate all the required fields onto the first page of the document and I'm using the .hidden property for the information to display or not based upon the selection made with a radio button for customer type - domestic or international. It seems to work fine so that's my workaround. It's unfortunate that Adobe provides a feature in Acrobat via scripting that only works in their $$ products. Anyway...thanks for the reply and happy holidays!

                                              • 20. Re: Carbon Copy Adobe Acrobat Form
                                                gkaiseril MVP & Adobe Community Professional

                                                You can not use Acrobat to create the form. You have to use LiveCycle Designer and create a dynamic form wth master pages.