• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

expire code....interesting

Participant ,
Jan 05, 2018 Jan 05, 2018

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript , Windows

Views

390

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 07, 2018 Jan 07, 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.

Votes

Translate

Translate
Community Expert ,
Jan 06, 2018 Jan 06, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 06, 2018 Jan 06, 2018

Copy link to clipboard

Copied

You mean like so,

{

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

this.closeDoc(true)

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

I understand the closeDoc, but I don't know how to do this bit. Could you show me how to do it so I can try it out and play around with it? Thanks, Try.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

LATEST

Read the documentation of the setTimeOut method of the app object. It's explained there in detail, including examples.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 06, 2018 Jan 06, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 06, 2018 Jan 06, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines