Search code examples
javascriptadobelivecycle-designer

liveCycle force close document


I was tasked to create a function to "protect" document with a password. I figured and the previous forms create a dialog asking for a password then validate it with the value in an hidden field on the form if they are not the same close the pdf file, I know this is not the most secure way to protect but the user is well aware of it and is fine with it "unless i can find a way to to automate the securing of the file.

My issue now is that i can't seems to be able to execute javascript code that would close the form "in liveCycle" because of security restriction implemented by adobe from what i understand.

I know that with acrobat pro i can use he command this.closeDoc(); to do this but everything i tried with live cycle (different version of app.execMenuItem("close"); & event.target.closeDoc(true); ) has failed to work. Any idea how i could force the security to allow one of those two command or to use another command to close the document programmatically?

Thanks


Solution

  • Try using this -

    app.setTimeOut('this.closeDoc(true);', 1);
    

    It worked for me for one of my requirements in the button 'click' event.