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

Problem with getPrintParams and two printers / default printer

pankov
Registered: Jul 21 2010
Posts: 1

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.

page 583 - printerName wrote:

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

brettville
Registered: Dec 20 2010
Posts: 2
I'm having this same problem
maxwyss
Registered: Jul 25 2006
Posts: 255
I may miss something, but why are you using a trusted function? As far as I remember (and understand the documentation), this is not needed.

What happens when you put the print code into the document itself?

Also, what happens when you switch the printerName / print blocks, and print to the "empty string" printer first?

HTH