Issue
If you are trying to close a PDF automatically using Javascript you may encounter differing behaviour depending on whether you are using Acrobat or Reader, and of course, depending on the version.
Solution
You should use the setTimeOut() method with the action defined as closeDoc(). The setTimeOut() method must be assigned to a variable in a top level object in the form, to prevent it from being garbage collected when a lower level variable goes out of scope.
In the form:ready event you should add the following script:
var discard = soUtils.closeDoc();
and then create a new Script object on the form with the following code:
function closeDoc() { var str = "This document will now close."; app.alert(str); return app.setTimeOut('this.closeDoc();', 1); }
Then the PDF should automatically close itself when opened in Acrobat/Reader.
Acrobat/Reader: how to close a PDF automatically through Javascript,