1 Reply Latest reply on Aug 29, 2011 8:15 AM by gkaiseril

    Print Dinamicly changed Julian Date in PDF

    PenchoD Ivanov

      I have to insert a script

      that will print on pdf file dinamicly changed date and time. The file will be printed on a Barcode Printer and will be loaded just one time with count 1000.


      The problem that i have is that i need to insert a date and time to be with Julian date in format for example 241 HH:MM - where 241 is the date, HH:MM is the time

      I found how to print pdf on the barcode printer with a date and time, but is only the normal way of date 29/08/2011 16:46

      Please to help me how to print the format to be in Julian Date


      The second problem that i have, is that i need to connect this script also with the time, if the time on the printer changed the time on the Barcode Label should also changed - without to reload the Print job for example i print on the Barcode Printer 100 labels per minute, so for 1000 labels

      i should have 100 with time 241 16:46, 100 with 241 16:47, 100 with 241 16:48 and etc......


      Thank you

        • 1. Re: Print Dynamical changed Julian Date in PDF
          gkaiseril MVP & Adobe Community Professional

          You can use the JavaScript date object to get the number of milliseconds from the Epoch date for the current date and for January 1st for the year. The difference will provide you with the number of milliseconds for the year, From this value you can easily get the number of days by some division.


          I am not sure, but it appears the 'Will Print' event will let you capture the printing event and do some limited processing prior to the PDF being printed.


          // document level script for reuse
          function oDate2Days(oDate) {
          var nDays = "";
          if(oDate != "") {
             // convert date object to number of days from Epoch date
             var nMillisecond = 1;
             // convert milliseconds to seconds
             var nSecond = 1000 * nMillisecond;
             // convert seconds to minutes
             var nMinute = nSecond * 60;
             // convert minutes to hours
             var nHour = nMinute * 60;
             // convert hours to day
             var nDay = nHour * 24;
             // convert date object to number of milliseconds since Epoch date
             var nDate = oDate.getTime();
             // convert to days since Epoch date
             var nDays = nDate / nDay;
             } // end not null  
          // truncate to whole days
          return Math.floor(nDays);
          } // end oDate2Days
          // end document level script

          // custom calculation script for field
          // get current dates object
          var oToday = new Date();
          // get Jan 1 this year object
          var oJan1 = new Date(oToday.getFullYear(), 0, 1, 0, 0, 0);
          // compute difference including today end point
          var nJulian = (oDate2Days(oToday) - oDate2Days(oJan1) ) + 1;


          // display results
          console.show(); console.clear();
          console.println("Today is: "  + util.printd("mmmm d, yyyy", oToday));
          console.println("Jan 1 this year: " + util.printd("mmmm d, yyyy", oJan1));
          console.println("Days since Epoch date for Today: " + oDate2Days(oToday) );
          console.println("Jan 1 this year days since Epoch date: " + oDate2Days(oJan1) );
          console.println("Julian date for today: " + nJulian);