How to expire a protected adobe PDF

Glenn Blog 0 Comments

Adobe PDF Portable Document Format is widely recognised as a preferred method for capturing and sending electronic documents in exactly the intended format. You can protect PDFs and limit copying, printing or even password protect opening them, but right now you can’t set them to ‘expire’ so that they can’t be opened / read past a certain date. That’s a really handy feature if you are sending a document like an offer / proposal that is time dependent. You might also want to limit the documents reach to undesirables / third parties that may be looking to use your spec / intellectual property and rip-off your content.

The following Javascript approach to expiring a PDF document has it’s limitations (which I’m purposefully not going to outline), but it does provide a neat interim approach to this problem.

Here’s how to expire your PDF on a certain date | Open a Dialog and then automatically Close

  1. Create your PDF (‘Print as PDF’ is a quick way to do this outside of Adobe’)
  2. Open up your PDF in Adobe Acrobat Pro DC (Part of Adobe Creative Suite and required for this advanced editing)
  3. Click on ‘Tools’ and then ‘Javascript’ – Add
    adobe-acrobat-add-javascript expire a protected adobe pdf How to expire a protected adobe PDF adobe acrobat add javascript
  4. In the Javascript Menu click on ‘Document JavaScripts’
    adobe-acrobat-document-javascripts expire a protected adobe pdf How to expire a protected adobe PDF adobe acrobat document javascripts
  5. This opens up the Document Javascript Dialog now under ‘Script Name’ Add the name ‘Expiry’ and click ‘Add’
    adobe-acrobat-document-javascript expire a protected adobe pdf How to expire a protected adobe PDF adobe acrobat document javascript
  6. In the JavaScript Editor delete everything so that it’s blank and then enter the following JavaScript

    
    function Expiry()
    {
    // Get the Expiry Date
    var ED = util.scand("dd/mm/yyyy","14/06/2016"); // Expiration date is 14th June 2016. Change this date to suit your needs
    
    // Get Today's Date
    var TD = new Date();
    
    // Validate and take measures!
    var diff = (((((ED.valueOf() - TD.valueOf()) / 1000) / 60) / 60) / 24); // Days difference
    if (diff < 1) {
    // Now the prompt...
    app.alert("Sorry this document has now expired. You cannot use this specific document any further.\n___________________________________________\n\nPlease contact someone@slickmedia.co.uk for an extension. Thanks.", 0, 0);
    
    // Dont Save and Close Document
    DontSave = true
    this.closeDoc(DontSave)
    };
    }
    
    // execute check expiration code
    Expiry();
    

  7. On the 4th line of the code change the date of “14/06/2016” to the expiry date that suits your needs and then enter your own message from line 13  and click ‘OK’
    adobe-acrobat-document-javascript-editor expire a protected adobe pdf How to expire a protected adobe PDF adobe acrobat document javascript editor
  8. That completes the code for the expiry and will open the expiry message when the date entered is passed and will then close the document, however we still need to protect the document.
  9. To protect your document on save Go to ‘File > Properties’  and click on the ‘Security’ tab
  10. Change the ‘Security Method’ to Password Security and then select your Security Restrictions. We generally don’t want people to Copy / Edit the Text, but we do want them to Print in High Resolution so we set our documents up like so:-
    adobe-acrobat-password-security-settings expire a protected adobe pdf How to expire a protected adobe PDF adobe acrobat password security settings
  11. Once you have made your selections add in the ‘Change Permissions Password’ and click ‘OK’. You will then be prompted to ‘.. confirm the Permissions Password’ and then hit ‘OK’ and come out of the Document Properties by clicking ‘OK’ again.
  12. Now go to File > Save As and Save your document. You are now done and can close your time dependent PDF document for distribution.

This is the finished article which will close shortly after the prompt is displayed:-

adobe-acrobat-pdf-with-expiry expire a protected adobe pdf How to expire a protected adobe PDF adobe acrobat pdf with expiry

About the Author
expire a protected adobe pdf How to expire a protected adobe PDF 0da77002febbfe28d15144a57bbcc2c9 s 180 d mm r g

Glenn

A highly experienced WordPress Web Developer, Front-end and Back-end Developer & New Media Specialist with extensive knowledge of a wide spectrum of technologies in the Development and Creative Industries built up over a number of years.

Leave a Reply

Your email address will not be published. Required fields are marked *