4 Replies Latest reply on Oct 8, 2009 4:12 AM by Bernd Alheit

    Time and Date Stamp Format and User name

    Johnny4321

      Hi All,

       

      I am very new to adobe acrobat so forgive my ignorance.  I am trying to add a date and time stamp to pdf files using adobe acrobat so that when they are printed using adobe acrobat the print date will be automatically added.  First I have found the below script on the forum which is entered as a field, will this work using acrobat version 5 or version 7?  Also i believe that the date format is 10/01/2009.  How can I change this so that it will be in the 01 October 2009 and 24 hour clock format?  Finally how do I also add some descriptive text before the date and time i.e. 'print date' and 'not valid 24 hours after printing'?

       

      var f = this.getField("today");

      f.value = util.printd("mm/dd/yyyy

      h:MM tt", new Date());

       

       

       

      One last question is there a way to add a user stamp to a pdf so that when the document is printed out the user's name is printed i.e. 'printed by J Smyth'.

       

      Many thanks,

      John

        • 1. Re: Time and Date Stamp Format and User name
          try67 MVP & Adobe Community Professional

          Yes, it should work with either version.

          Change the second line to this if you want the format you specified:

           

          f.value = util.printd("dd mmmm yyyy HH:MM", new Date());

          • 2. Re: Time and Date Stamp Format and User name
            gkaiseril MVP & Adobe Community Professional

            As noted, you need to change the formatting string to generate the date appearance as you need. You can add additional text to this string using the concatenation string operator, '+'. So you can do:

             

            var f = this.getField("today");

            var sDate = util.printd('dd mmm yyyy HH:MM tt", new Date())

            f.value = 'Print date: ' + sDate + ' not valid 24 hours after printing';

             

             

            All of the above information is covered in Adobe's freely down loadable Acrobat JS API and there are additional resources for JavaScript programing at the Acrobat Users Community and Planet PDF.

             

             

            Accessing the 'identity' object is more complex. First, all users will need to complete the 'Identity" information for the application's preferences, as only the login name is picked up from the OS. Then each user will need to have an application folder level JavaScirpt installed on their computer to capture this information during the application initialization of Acrobat/Reader

             

             

             

            // Folder level script to create an application level variables for the "identity" objects properties
            var Identity = new Array(); // array for the identity objects elements
            Identity.Corporation = identity.corporation;
            Identity.Email = identity.email;
            Identity.LoginName = identity.loginName;
            Identity.Name = identity.name;

             

            // or
            var Identity = new Array();
            for (i in identity)
            Identity.i = identity.i;

             

             

            You can then access the items in a PDF  by adding the array element name to the Identity array:

             

            // set a fied's value to the value of:

            this.getField("loginName").value = Identity.LoginName;
            this.getField("name").value = Identity.Name;
            this.getField("by").value = "By: ";
            this.getField("by").value += Identity.Name;

             

            You can find the necessary JavaScript folders for Acrobat using the following code in Acrobat's JavaScript debugging console:

             

            app.getPath("app","javascript");
            app.getPath("user","javascript");

            • 3. Re: Time and Date Stamp Format and User name
              Johnny4321 Level 1

              Hi,

               

              Thanks for the information but I'm still a bit stuck.  When I try to follow the instructions below I cannot find the "Document Processing" or "Will Print" options in Acrobat Pro Version 7, I can only find "batch processing".  Are these options only available in later versions of Acrobat?

               

              Add a field with the name Today to your document and place the following code in the "Will Print" document action, "Advanved => Document Processing => Document Actions => Document Will Print..." popup window.

              var f = this.getField("Today");
              f.value = util.printd('dddd dd mmmm yy h:MM tt', new Date());

               

               

              Thanks

              John

               

              I

              • 4. Re: Time and Date Stamp Format and User name
                Bernd Alheit Adobe Community Professional & MVP

                Use the menu Advanced > Document Processing > Document JavaScripts...