Skip to main content
Participating Frequently
June 13, 2017
Answered

I want to create a javascript in acrobat to automatically close a document only when password security is on

  • June 13, 2017
  • 1 reply
  • 648 views

I want to create a javascript in acrobat to automatically close a document only when password security is on

This topic has been closed for replies.
Correct answer try67

Ah, I see... You are aware there are many ways to get around such "protection", right?

You can use this code to do it:

if (this.securityHandler!=null) {

    var toObj = app.setTimeOut("this.closeDoc(true);", 300000);

}

Note: I didn't test this code. It's possible it will not work correctly. For example, if the user switches to another file during these 5 minutes, I believe the code will try to close that file... There might be ways around that, but it's getting more tricky.

1 reply

try67
Community Expert
Community Expert
June 13, 2017

Do you mean a script that's embedded in the file that automatically closes it if that file is secured?

If so, you can try this code:

if (this.securityHandler!=null) this.closeDoc(true);

Participating Frequently
June 13, 2017

Yes, but to automatically close out in 5 minutes

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 13, 2017

Ah, I see... You are aware there are many ways to get around such "protection", right?

You can use this code to do it:

if (this.securityHandler!=null) {

    var toObj = app.setTimeOut("this.closeDoc(true);", 300000);

}

Note: I didn't test this code. It's possible it will not work correctly. For example, if the user switches to another file during these 5 minutes, I believe the code will try to close that file... There might be ways around that, but it's getting more tricky.