3 Replies Latest reply on May 14, 2008 9:22 AM by gkaiseril

    Placing current page number on all pages

      I am new to JavaScript in Acrobat and I have what I believe to be a simple question.

      I have a multipage document that I need to place certain information on each page. On page 1 I have some form fields that the user can input specific information in and I have 1 output field that concatenates these and places it on all subsequent pages. As part of the output field I need to include a page number. This is the only part I have not been able to figure out.

      As an example:
      Page 1 will have the following input fields and values:

      Input1 --> "This is"
      Input2 --> "Page"

      The output field on all pages will be as follows:

      Page1 --> "This is Page 1"
      Page2 --> "This is Page 2"

      The actual input fields will include information specific to when and how this document was printed. The output field will be converted to a barcode to enable automatic reading of the printed file.
      I want a single field for my output that I will copy to each subsequent page. I don't want to place a unique field on each page for many reasons.

      I can email a sample of what I am trying to accomplish if that would be helpful.

      I am using Acrobat Professional 8.1.2.

      Any help would be greatly appreciated.

      Thanks
        • 1. Re: Placing current page number on all pages
          gkaiseril MVP & Adobe Community Professional
          Since you are using many fields, you should consider not using the "Custom calculation script" for the page number fields, as all of these fields will be re calculated whenever any field with a calculation is updated. One can create a document level function to number the pages upon opening. Assuming you have systematically named your page number fields in a format like "PageNum.#", where "#" is the zero based page number on which the field resides.

          function NumberPage(fPage) {
          this.calculate = false; // turn off automatic calculations
          this.getField("PageNum." + fPage).defaultValue = "This is Page " + (fPage +1); // set value if form is cleared
          this.getField("PageNum." + fPage).value = "This is Page " + (fPage +1); // set display value
          this.caclulate = true; // restore automatic calculations
          }

          // loop through each page
          for(i = 0; i < this.numPages; i++)
          NumberPage(i); // number each page
          • 2. Re: Placing current page number on all pages
            Level 1
            Geo,
            Thanks for the reply.
            I hadn't thought of using document level code but that might work better than using the calculation script as you have pointed out.
            I am still confused about 1 point however.

            >Assuming you have systematically named your page number fields in a format like "PageNum.#", where "#" is the zero based page number on which the field resides.

            If I understand this correctly I will need to place unique fields on all pages to accomplish this. Is my understanding of this correct?

            If this is the case it won't work for me. One of the reasons I want to have a single output field is if I need to delete or add pages in the middle of the document I wouldn't need to adjust all of the subsequent field names in order for a loop to work correctly.
            • 3. Re: Placing current page number on all pages
              gkaiseril MVP & Adobe Community Professional
              Yes, text fields need to be unique because if they all have the same name they share all the same properties including value. You could also create a document level script to use the "removeField" to remove the page number fields and then add new fields for the page numbering.