2 Replies Latest reply on Aug 9, 2011 8:48 AM by George_Johnson

    Close File 24 hours After Opening


      (Not having experience with pdf java script), I've been trying for 5 or 6 weeks to write a script - to be placed in Document Scripts (I'd prefer to say away from form fields) - that keeps a file open 24 hours after it's first launched––and then closes. (It's a 24 hour trial version).


      I've tried different configurations. (This following script works but doesn't serve my goal: Reason is, in the script below, the "final date" is fixed. The final date  has to be calculated as 24 hours (1440 * 60 * 1000) after the initial launch date.):

      var curDate = new Date();
      var finalDate = new Date("8/08/2011");
      if(finalDate.getTime() < curDate.getTime())


      I've tried using the following as the launch date but I can't make it work:

      var f = this.getField("Today");
      f.value = util.printd("mm/dd/yy", new Date());


      The user is free to open and close the file during the 24 hours: So: I'm also concerned that the initial "curDate" remain stable. If it doesn't, I must change that part of the script as well and use a "Date the file was opened" as a variable. I've triend to use calcluations - but have not been able to succeed. At least, I figured out, there are 3 variables: the open-file-date, the 24 hours after open file date, and current date. In the end, I check to see if the 24-hours-after-open file is < than current date and if so, closeDoc. At least I learned that much.


      Can anyone help me? I bet it's simpler than what I'm making it out to be, but I'm burnt to a crisp - I've spend all my time on this and have come to realize, it's  above my skill level and could use some help..... thank you in advance