Here's a simple way that works with Adobe's Acrobat Reader and maybe some other readers (but not all others--e.g., Sumatra ignores the expiry entirely), based on combining two ideas I found online. It only works on PDFs that haven't already been compressed or encrypted. Load the PDF into a text editor. Find the code /Type /Catalog. Insert this bit of code right after that code, changing the date to match your needs:
/Type /Catalog
/Names <<
/JavaScript <<
/Names [
(EmbeddedJS)
<<
/S /JavaScript
/JS (
var rightNow = new Date();
var endDate = new Date(2018, 7, 10); // expiry date: year, month (0=Jan, 11=Dec), day
if(rightNow.getTime() > endDate)
{
app.alert("This document has expired.");
this.closeDoc();
}
)
>>
]
>>
>>
Then load it into Acrobat Reader. Acrobat Reader should display it, but when you exit it will ask to save the file. Agree, as this will hide the above code and make it no longer easy to edit.
No comments:
Post a Comment