These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Expire a document

pdfer
Registered: Dec 23 2010
Posts: 28

I'm using the following Javascript to Expire the document:
 
function Expire()
{
// Get the current date and time
var rightNow = new Date();
// Setup End Date
var endDate = new Date("January 12, 2011 11:15:00 AM");
if(rightNow > endDate)
{
app.alert("The trial period has expired. Contact the owner for additional access rights.", 1, 0);
this.closeDoc()
}
}
 
// execute check expiration code
Expire();
 
which works very well. The only thing is the user can turn their computer's date backwards and bypass the security. Does anyone know how to write a code that would give the user a period of time, let's say from 1/12/2011 @ 10:00:00 AM to 1/15/2011 @ 11:30:00 PM to use the document. Then on any other date and time would expire.
 
There has to be a Javascript that is capable of doing this. If the code above can expire a doc using a future date. Then there has to be some coding that can do it backwards and forwards. And, yes it has to be Javascript (for the time being). Can someone help?

Jackson C.

My Product Information:
Acrobat Pro 9.0, Macintosh
try67
Expert
Registered: Oct 30 2008
Posts: 2398
It's possible, but that will not solve your problem. The user can change the local date on their machine to a date that falls between these two dates and use the file without a problem.

If you really want to do it, you can add something like this to your code:

var rightNow = new Date();
var beginDate = new Date("January 12, 2011 11:15:00 AM");
var endDate = new Date("January 15, 2011 11:15:00 AM");
if (rightNow < beginDate || rightNow > endDate) {
... etc

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
As noted the time for the computer can be changed.

A bigger problem will be a sysadmin that turns off JavaScript per the security warning of Adobe and locks the ability of the user to modify this preferences. Or the user who turns off the JavaScripbt.

I would start with a big text field over the form that blocks access until it determined that JS is available. This is done by hiding the field using JS. This feature has the limitation that a user with a full version of Acrobat could edit the field. Also a user of that skill could also remove the JS.

George Kaiser