Skip to main content
Known Participant
January 6, 2018
Answered

expire code....interesting

  • January 6, 2018
  • 2 replies
  • 770 views

I'm using this working expire code,

function Expire()

{

// Get the current date and time

var rightNow = new Date();

// Setup End Date

var rightNow = new Date();

var beginDate = new Date("January 11, 2017 06:15:00 AM");

var endDate = new Date("January 12, 2018 11:57:00 AM");

if (rightNow < beginDate || rightNow > endDate)

{

app.alert("you are not allowed to view this doc.", 1, 0);

this.closeDoc(true)

}

}

Expire();

what I'd like to know is can I modify the endDate to expire right now when I click a button. If that can be done can someone let me know how? Thanks for your help.

PS: I know all the possible workarounds to defeat the code so please don't reveal them if you reply. I just don't want to educate those unscrupulous people looking for that kind of help.

This topic has been closed for replies.
Correct answer try67

Yes, that's it. If you want to make the file usable for a while after the button is clicked and before it is closed you can use the setTimeOut method to delay the execution of the closeDoc command.

2 replies

Legend
January 6, 2018

You mean you want it to remember that the button was clicked for the next open? Very challenging, you’d have to save the file.

pdfUser1Author
Known Participant
January 7, 2018

Saving the doc isn't a concern for me. The doc should just slam shut when the button is clicked after a date. I got a little closer with Try's help. But, after using it and trying it out I became aware that the doc should be usable for a period of time, even if the close button is clicked. But, then if I don't want the user to use the doc anymore, then the close code would be effective and shut the doc.

Sounds a bit confusing I know but even with the original expire I mix it up with other script (like the reset feature) then I obfuscate all the code, then password the doc. Seems to help a little and nothing is perfected, but we must try to protect the code.

try67
Community Expert
Community Expert
January 6, 2018

You don't need all of it to do that... Just the closeDoc command.

pdfUser1Author
Known Participant
January 7, 2018

You mean like so,

{

app.alert("you are not allowed to view this doc.", 1, 0);

this.closeDoc(true)

}

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
January 7, 2018

Yes, that's it. If you want to make the file usable for a while after the button is clicked and before it is closed you can use the setTimeOut method to delay the execution of the closeDoc command.