These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

closeDoc crashes Acrobat

John Renfrew
Registered: Jun 7 2010
Posts: 13
Answered

I am busy trying to learn some more advanced techniques and

if i do closeDoc() from the java debugger it works fine

but if i add this as a document action on did Save (thought I might be clever and have self closing doc you see) it does indeed close but it also crashes Acrobat Pro. Mac or PC doesn't make a difference

Some pointers to other posts if necc. would make my afternoon less rainy..

My Product Information:
Acrobat Pro 9.3.1, Macintosh
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Yes it does - because the parent context (the document action) vanishes before the closeDoc event has wrapped up. To quote the SDK:

[i]It is important to use this method carefully, because it is an abrupt change in the document state that can affect any JavaScript executing after the close. Triggering this method from a Page event or Document event could cause the application to behave strangely.[/i]

"behave strangely" is SDK-speak for "explode". You can fire the closeDoc event through the console because the debugger persists even when the document is closed, and you can assign it to a menu item or shortcut for the same reasons (it's parented to app, which remains alive) - but not to a document action. It's the same reason you can't close the application from an event.