6 Replies Latest reply on Jan 28, 2015 7:28 AM by gkaiseril

    Spawning pages with page numbers "page 1 of 1"

    Piscus33

      I'm using a calculation script to define "page 1 of 2" in a form. The script is as follows.

       

      //set the page number to number 1

       

      this.pageNum = 1;

       

      //use the page of page format

       

      event.value = "Page " + (event.target.page+1)+" of " + (this.numPages);

       

      This works fine, however, when I start spawning pages the numbers get mixed up. For example, if I spawn one page, the "page 1 of 1" on page one changes to "page 1 of 2." On page two, it reads "page 0 of two." I just can't seem to get the "page n of n" to work with spawned pages. Any suggestions would help.

       

      Thank you

        • 1. Re: Spawning pages with page numbers "page 1 of 1"
          try67 MVP & Adobe Community Professional

          The first line of the script is not necessary, just the second one.

          And did you set the parameter to rename the fields on the spawned pages to true?

          • 2. Re: Spawning pages with page numbers "page 1 of 1"
            Piscus33 Level 1

            I will remove the first line.

             

            Yes, the rename parameter is set to rename the fields.

            • 3. Re: Spawning pages with page numbers "page 1 of 1"
              try67 MVP & Adobe Community Professional

              Try adding a call to this.calculateNow() after spawning the pages to make sure the fields are updated.

              • 4. Re: Spawning pages with page numbers "page 1 of 1"
                gkaiseril MVP & Adobe Community Professional

                For each page's field number page you need to go to that page in the calculation script. You could also turn off calculations during the spawning of the pages and then turn it back on and recalculate the form.

                 

                // code to spawn template;
                // turn off automatic calculation;
                this.calculate = false;
                var t = this.templates;
                var T = t[0];
                T.spawn(this.numPages, true);
                // trun automatic calculation back on;
                this.calculate = true;
                // force recalculation;
                this.calculateNow();
                // end spawn template;

                 

                // custom calculation script for numbering pages;
                var cField = event.target.name;
                var aField = cField.split(".");
                if(aField.length > 1) {
                // get page number for form field from field name & go to that page;
                this.pageNum = aField[0].substr(1,1);
                // update field's value;
                event.value = (this.pageNum + 1) + " of " + this.numPages;
                // update field's default value;
                event.defaultValue = event.value;
                }
                // end custom calculation for numbering pages;

                • 5. Re: Spawning pages with page numbers "page 1 of 1"
                  mikek78090962

                  Sorry for the intrusion, GKaiseril,

                   

                  It's been MANY years since I last used JetForms and now need to refresh my Page Of skills.

                   

                  From what I can recall, there was a very simple method of selecting/activating the Page Of capabilities on a form without having to do the scripting detailed above.

                   

                  Either way, I've completely forgot how to get the Page Of feature to work...Could you describe, in minute details how to get Page Of's to print.  For instance, I can somewhat follow what you wrote above, but as I stated I don't recall doing the scripting before so I have no idea where to place this code.

                   

                  Thanks in advance.

                   

                  Mike

                  • 6. Re: Spawning pages with page numbers "page 1 of 1"
                    gkaiseril MVP & Adobe Community Professional

                    This is for Acrobat forms which is very different from LiveCycle (formerly Jetforms) in the way they are scripted and some of the features work.