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

Adobe Reader JavaScript

wush
Registered: Feb 1 2010
Posts: 3
Answered

Hello,
i need a Quick Print Button for adobe Reader 9.
Actually there pops up a Print Window where i choose the Printer and more options.
Do you know a way to prevent or automatically catch and confirm the Print Window with Adobe Reader JavaScript or Registry Settings?

Unfortunately any Stand-Alone Scripts (like auto-it or Jscript/Windows Script Host) are not an acceptable solution.
The script or modification must be done IN Adobe Reader.

Any help appreciated!!

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
If you don't allow your users to choose their settings in the dialog window, how are they going to pick which printer to use, what scaling or paper size, etc?

Non-interactive printing is only permitted via privileged scripts (menu / batch / folder-level) as in those situations you're creating the script for local use, so you know the hardware and output you want and can specify your scripted settings accordingly.
wush
Registered: Feb 1 2010
Posts: 3
Hello Uvsar,
the users should not to be able to change any settings. Its a KioskSystem.
There is only one Printer in the system settings and default printer settings are just fine.


Quote:
Any object, function or property in the Acrobat JavaScript Reference marked as privileged is potentially dangerous and can only be run from a privileged context
Well the XP User is not an Administrator. Should i gave up now?
If not.. do you have a Code Example for me howto print non-interactive? I've no clue
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
As I said, you cannot initiate a silent print action from a script inside the PDF, only from external scripts.

Example - place the following code in a file named "silentPrint.js" and put it in your Adobe/Acrobat 9.0/Acrobat/Javascripts folder. Close and re-open Acrobat to load the script:

Quote:
trustedSilentPrint = app.trustedFunction( function (_thisdoc) {
app.beginPriv();
var pp = _thisdoc.getPrintParams();
pp.interactive = pp.constants.interactionLevel.silent;
_thisdoc.print(pp);
app.endPriv();
})
Now add a button to your PDF, set the action to "Run a JavaScript" and enter the one line:

Quote:
[b]trustedSilentPrint(this);[/b]
Press the button and your PDF will print to the default printer without any dialogs. To use it on your kiosk, copy the JS file to the Adobe/Reader 9/Reader/JavaScripts folder on that machine.