Adobe Reader DC automatically print any opened file using javascript

New Here ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

A client requires that any opened PDF file in Acrobat reader to be printed automatically at the default printer.
I found a script that can do that, but it seems that Adobe Reader DC (last version) does not execute it, even though the sprint is in the app javascript folder C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\Javascripts\
the script is here:

```/*
* trustedPrint function: Exercise the print function in the privileged context
*
* @Param doc The Doc object of the target document
* @Param pparam The PrintParams object containing print settings
*/

trustedPrint = app.trustedFunction(
function(doc, pparams) {
app.beginPriv();
doc.print(pparams);
app.endPriv();
}
);

/**
* Main function: Print silently if requested
*
* @Param theDoc The event target of executing the menu item of this sample.
*/

function JSPrintExt(theDoc,printerName,silent) {
// get the printParams object of the default printer
var pp = theDoc.getPrintParams();

if (silent) {
// print all pages silently.
pp.interactive = pp.constants.interactionLevel.silent;
}
for (var i=0; i<app.printerNames.length; i++) {
if (app.printerNames[i].toLowerCase().indexOf(printerName) > -1) {
pp.printerName=app.printerNames[i];
}
}


// Print to the default printer without invoking the print dialog
trustedPrint(theDoc, pp);

}```

TOPICS
JavaScript, Print and prepress

Views

66

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 26, 2021 Mar 26, 2021

Copy link to clipboard

Copied

LATEST

What code do you add to the PDF, and where do you put it?

What messages do you get in the JavaScript console?

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines