Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Close Acrobat with Javascript

Posted on 2006-06-28
11
Medium Priority
?
3,037 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
11 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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…
*Adobe Acrobat 9 was used for this article.  Particular steps may vary depending on software versions. Adobe Acrobat has many, many variables that my be utilized to customize your forms for clarity and ease of use. The Form Editing Tool will be y…
In this third video of the Xpdf series, we discuss and demonstrate the PDFtoText utility, which converts PDF files into plain text files. Download and install the software.: You may have already downloaded and installed the Xpdf tools while watching…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

618 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