[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Close Acrobat with Javascript

Posted on 2006-06-28
11
Medium Priority
?
3,078 Views
Last Modified: 2008-01-09
I have a pdf document that opens, pulls information from a text file which populates the fields in the document, and then automatically prints.  I can get the pdf to close automatically, but I would like to close the Acrobat application instead.  Is there any way to close Acrobat with javascript?
0
Comment
Question by:jerf26134
  • 6
  • 3
9 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 17002727
No, you cannot do that. The App object does not have a "Quit" or "Close" method, and it's no longer possible to execute the menu item that would close Acrobat. So you have to live with Acrobat staying open after your document closes. As far as I know, there is also no mechanism to minimize the Acrobat window from JavaScript.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 17002749
Forgot one thing: The "no longer possible" means that up to Acrobat 5 it was possible to execute that menu item from a JavaScript program. With Acrobat 6 Adobe decided to (for security reasons) no longer allow that.
0
 

Author Comment

by:jerf26134
ID: 17003577
That's what I was afraid of.  I can get Acrobat to close via a button using the execMenuItem, just not in a script when the page opens.  Do you know if there is any way to trigger a button on Page Open?  

If so, that would be just as good because I could set up a button that does not print and accomplishes the same thing.
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 17003627
Which version of Acrobat are you using? According to the documentation, this should no longer work.

Also, have you considered what happens if somebody already had Acrobat open when your document loads? If you try to quit Acrobat after the document closes, that will not take into account any other open documents. This may not be what the user wants.
0
 

Author Comment

by:jerf26134
ID: 17005198
I am using 7.0 but the majority of the users are still using 6.0 (which I haven't tested yet).  I have a line of javascript attached to the print button (this.print() ) and follow it up with an Execute a Menu Item - Exit.  It works in 7.0 which surprised me, but doesn't on Page Open, just Mouse Up.

This is in a mass production type of environment and most of the people dont have acrobat up with any other document while running this so that really isnt an issue for me.  I agree though that I would be extremely angry if I were working on another pdf and it suddenly closed without any warning.  Unfortunately we want to idiot-proof this as much as possible by taking as much of the user interaction out as possible...but they keep making better idiots.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 17008561
I can only quote the JavaScript Reference: "For security reasons, scripts are not allowed to execute the Quit menu item" - this is from the 7.0.5 version of AcroJS.pdf. Adobe could consider the current behavior a bug and fix it in the next patch to Acrobat or Reader. I would not rely on this (undocumented) behavior in a commercial environment.
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 17008588
When I run the command app.execMenuItem("Quit"); in the JavaScript console, I get the following error:

app.execMenuItem("Quit");
NotAllowedError: Security settings prevent access to this property or method.
app.execMenuItem:1:Console undefined:Exec

This is with Acrobat 7.0.8 Professional. As far as I know, all restricted functions are allowed in a console environment.
0
 

Author Comment

by:jerf26134
ID: 17010978
I get the same error when its run from javascript, but what I have is a line of javascript that runs and after that finishes, a separate 'execute menu item' that isnt javascript closes the application.  So my button has the actions on MouseUp:
Run Javascript (which is the print part)
Execute Menu Item (Exit)

Is there a way for Acrobat to automatically act as if the button was pressed on openning the pdf?
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 2000 total points
ID: 17011299
I see, you are not using JavaScript. That's interesting. I did not know that they allow that.

As far as I know, you cannot execute a button without user interaction. I am not aware of a JavaScript command that would do that, but I also don't know of any plug-in API function that would allow you to execute a button.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
The Adobe PDF proprietary file format is recognized as secure and formulated. But these PDF files are also prone to corruption and any external threat like virus attacks, improper storage can hit PDF file integrity.This type of damages can make cruc…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses
Course of the Month20 days, 11 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question