开发者

Generation PDF with PHP including an expiration date

开发者 https://www.devze.com 2023-03-09 19:17 出处:网络
I have to send some text-information from the webserver to the users. Unfortunately, this text have to be destroyed (which means access to the information should be deny) after 7 days. So one idea is

I have to send some text-information from the webserver to the users. Unfortunately, this text have to be destroyed (which means access to the information should be deny) after 7 days. So one idea is to create an pdf with an "expiration date" inside, in order to get an file which is unable to open, after the 7. day. Is this possible with PHP?

But how to start?

I don't need an solution which is 100% safe. The responsibili开发者_Go百科ty will be transferred to the user, if he goes an forbidden way to safe, copy or manipulate this document. I hope to find a way, to make the content unreadable (even it is (only) the first impression). But it looks like, there will be no way.


Once the PDF is generated, it cannot be "destroyed". There's no support in PDF for "do not open after 7 days", and such support is ENTIRELY dependent on the pdf viewer app honoring it. Nothing says the user can't reset their system clock back to a date/time that would fall within the PDF's viewing limit anyways.

PDF's (in)security flags are limited to encrypting the document so it can't be edited, and some flags to SUGGEST to the pd viewer that printing, screen reading, or text scraping should be forbidden. But they're just SUGGESTIONS and the PDF viewer is free to interpret/ignore them any way it wants.

Ultimately, this security "system" would be useless and trivially bypassed. And since it's browser-based, there is absolutely nothing you can do to control the remote user's machine to prevent the data from being downloaded/cached/saved in some form.


Content expiration is really an impossible problem. You can create some page that will be cleared after 7 days, but can't prevent people to copy the content to some other place.

All existing 'solutions' to this problem depend on Security through Obscurity. Which means people won't be able to get around your 'security' because they don't know how it works, and not because it is secure by nature.


You can put the contents in a hidden form field. You can then add a JavaScript PDF action for the document open event so that the Javascript script will check the date and display the form field. This will work only if the end-user is using Adobe Reader. I am not sure whether there are other PDF viewer that support Adobe PDF Javascript.

This kind of security is a bit amateurish. As mentioned by another repsonder, the end-user can change the system date and the bypass the security measure.

If the JavaScript can obtain from a https webserver with a digital certificate, then perhaps this will work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号