We are developing a web based application which needs to print labels (stickers) with two different formats and print them to two different printers without additional confirmation from the user.
For this we are generating PDF files which explicitly use a custom print function defined in .js file stored on the client's computer.
The function looks like this
sSpdPrint = app.trustedFunction( function(sPrinterName){ app.beginPriv(); var pp = this.getPrintParams(); pp.printerName = sPrinterName; pp.interactive = pp.constants.interactionLevel.automatic; this.print(pp); app.endPriv(); } )
In the JavaScript for Acrobat API Reference PDF document it says explicitly that if the printer name is an empty string the default printer will be used.
The name of the destination printer. This property is a Windows-only feature. Currently, the destination printer cannot be set through this property in Mac OS.
By default, printerName is set to the name of the default printer. If you set printerName to an empty string, the default printer is used. When printerName is an empty string and fileName is a nonempty string, the current document is saved as a PostScript file. See Example 2 below.
Sadly this is not working and I think there is a bug because if the function is called two or more times and the first time a real printer name is used and the other no printer name is provided with the intention of using the default printer nothing gets printed on the default printer - everything is printed on the specified printer in the first call.
Here is an example that can be used to prove it
sSpdPrint = app.trustedFunction( function(){ app.beginPriv(); var pp = this.getPrintParams(); pp.interactive = pp.constants.interactionLevel.automatic; pp.printerName = "Test Printer 1"; this.print(pp); pp.printerName = ""; this.print(pp); app.endPriv(); } )
The result is two copies printed on printer "Test Printer 1" instead of only one copy on "Test Printer 1" and one at the default printer.
Strangely if we switch the printing order - first print to the default printer and then to the specific one it works correctly ... but only the first time it's called. The second call prints everything to the specified printer.
So the question how can we force the Adobe plug-in again to use the default printer, not the previously specified one using the printerName property?
Are we doing it wrong or there is really a bug?
We've tested it with Adobe Reader 9.0 and 9.3.3