2 Replies Latest reply on Oct 5, 2009 2:19 PM by Jo_2005

    Add a field to the last page of a document file only

    Jo_2005 Level 1

      Hello,

       

      I currently have a script which will add signature and text fields to the first page of a document.

       

      The script is required to specify the "last page" of the document and not the page number, as each file will vary with the number of pages.

       

      The script is in run in batch processing on multiple files which are not open (usually 50 at a time).

       

      If anyone can please advise how to modify the script I will be most grateful.

       

      // Create Date field dynamically for employee signature field


      var f = this.addField("Todaydate", "text", 0,
      [60, 54, 135, 75]);

      f.userName = "Today's Date";
      f.value = "Automatic Update";
      f.readonly = true;
      f.fillColor = color.ltGray;

       

      // Create signature field dynamically for employee


      var f = this.addField("mySignature", "signature", 0,
      [120, 85, 330, 105]);

      f.setAction("OnFocus", "var f = this.getField('Todaydate'); f.value = util.printd('d/mm/yyyy', new Date());");

       

       

        • 1. Re: Add a field to the last page of a document file only
          try67 MVP & Adobe Community Professional

          Change the third parameter of this.addField from 0 to this.numPages-1

          • 2. Re: Add a field to the last page of a document file only
            Jo_2005 Level 1

            Thank you very much for your help, I really appreciate your quick response.

             

            The script has been modified as you suggested and the fields are now added to the last page of each document and is working perfectly.

             

            I have included the modified script as follows for reference:

             

             

            // Create Date field dynamically for employee signature field, add fields to the last page of every file

            // Determine the last page of this document

             

            var page = this.numPages - 1;


            var f = this.addField("Todaydate", "text", page,
            [60, 54, 135, 75]);

            f.userName = "Today's Date";
            f.value = "Automatic Update";
            f.readonly = true;
            f.fillColor = color.ltGray;

             

            // Create signature field dynamically for employee


            var f = this.addField("mySignature", "signature", page,
            [120, 85, 330, 105]);

            f.setAction("OnFocus", "var f = this.getField('Todaydate'); f.value = util.printd('d/mm/yyyy', new Date());");