Skip to main content
Participant
March 21, 2008
Question

How to set a PDF to expire (Working Script)

  • March 21, 2008
  • 35 replies
  • 89952 views
Here is a little script I made up the other night. You can use it to allow a PDF to be opened only until a set date. I use this for when my employees go to service a customer. I want them to be able to see the customer's information, but only for 24 to 48 hours.<br /><br />CheckExpiration()<br /><br />function CheckExpiration()<br />{<br />/*-----START EDIT-----*/<br />var LastDay = 21<br />var LastMonth = 3<br />var LastYear = 2008<br />/*-----END EDIT-------*/<br /><br />/* DO NOT EDIT PAST HERE !!! */<br />var today = new Date();<br />var myDate=new Date();<br />LastMonth = LastMonth - 1<br />myDate.setFullYear(LastYear,LastMonth,LastDay);<br /><br />if (myDate<today)<br /> {<br /> this.closeDoc(1);<br /> app.alert("This files has expired.",1,0,"Expired");<br /> }<br />}
    This topic has been closed for replies.

    35 replies

    Participant
    March 12, 2009
    I'm not familiar with the JavaScript API, but is there a way to modify document appearance with the API? If so, then the document could be rendered in an unreadable format (e.g. white print on white background) and the JavaScript could check the date and modify the appearance. Thusly, if JavaSript were disabled, the document could be opened but not "used".

    Yes, I understand that any of these measures can be likened to a lock on a screen door, but sometimes that's all you need to redirect the actions of the "almost honest".
    try67
    Community Expert
    Community Expert
    January 11, 2009
    Switching off JavaScript can be done from within Acrobat, so Active Directory can't prevent it. The layer option is good... I thought of another one -- hiding the pages in templates that are made hidden only when JavaScript is enabled and the script has not yet expired. Of course, an experienced user can display the pages themselves, but it would work for most.
    Participant
    January 11, 2009
    Not a big expert on wondows active directory but I am sure within active directory there is an option to force users not to be able to switch off programs like javascript.

    The solution you have proposed here is actually quite handy. As mentioned this is really to help protect honest people. If you need something more secure I would suggest looking at windows active directory, although off course you need to be running this service in the first place.

    Regards. Peter.
    DimitriM
    Inspiring
    January 10, 2009
    Hi Melissa,

    Yes, the problem with all these solutions is that in order to make them work JavaScript must be turned on. But your mention of a "cover" document explaning to the user that JS must be turned on is possible. There is an example PDF at-

    AcroDialogs Product Page

    Scroll down to the link for "Document License Dialog Example" to download it. If the user does not turn JS on then they cannot view the information under the "cover" layer. If JS is already turned on then they can view it.

    Again, this is not an airtight security method, just a pretty good deterrent.

    Hope this helps,

    Dimitri
    WindJack Solutions
    www.windjack.com
    www.pdfscripting.com
    Participant
    January 10, 2009
    Too bad we can't turn this around and somehow require Javascript is ON and then proceed. Maybe a pair of documents, first one that checks for Javascript that shows a link to the second document with the time sensitive data. Again, not a long term solution.
    Participant
    December 18, 2008
    Allegra Pilosio, you said the script to expire PDF is working. To restrict opening the file in Illustrator or Photoshop, you can set the document secruity in PDF.

    Use clt+D or Cmd+D, choose password security
    Compactibility: Acrobat 3 or later
    Encrypt All document contents
    Set a Password
    Printing Allowed: High Resolution
    Changes Allowed: None

    Thats it, people can't open your PDF in Photoshop or in Illustrator without knowing the password
    Participant
    December 16, 2008
    Hello,

    Using SteveMajor's method of having the pdf checked against a script on a website, is it possible to cross check against the date a pdf is created on the user system with a expiry. To put it simply, i want a user downloading a copy of pdf from my intranet to be able to use it for 24 hours only (the counter starting from the time it is downloaded on the user system). This is to ensure some form of document control / version control.

    Thanks!
    Participant
    November 20, 2008
    I am interested in enabling the method of SteveMajors - Aug 1, 08 PST (#24 of 31). I have tried doing it, but it is beyond my knowledge of what i need to do or how to do it.

    I don't know if or whether the options he advocated are necessary or not. I believe he was populating his form from his server, so disabling the script blocks access to the file as well. However, I would like to start with something simple like just the date being sent from my server.

    I think my problem is in properly setting up the .php code and capturing it in acrobat (instruction #6).
    Bernd Alheit
    Community Expert
    Community Expert
    September 18, 2008
    Or any user with an other PDF viewer.
    Inspiring
    September 18, 2008
    Just be aware that any user who turns off JavaScript in their copy of Reader or Acrobat will not be restricted by this approach.