Set default printer in a pdf created with Aspose.Pdf

On a website, we have to create a pdf with address labels.

Since the customer has a dedicated label printer, it would be nice if the default printer could be set right into the pdf document while we create it.

With the following code we are able to open the printer dialog when a pdf is opened.
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(filePath);
doc.OpenAction = new JavascriptAction(“this.print({bUI:true,bSilent:false,bShrinkToFit:true});”);

Question: Is it possible to set the printer to be used as default in a similar way?

Hi Manuel,


Thanks for your inquiry. If you would like send the file to a particular printer, you may specify the printer by setting the printerName property of the PrintParams object in java script, as following. Hopefully it will help you to accomplish the task.

Aspose.Pdf.Document
doc = new Aspose.Pdf.Document(myDir+“helloworld.pdf”);<o:p></o:p>

doc.OpenAction = new JavascriptAction("var pp = this.getPrintParams();pp.interactive = pp.constants.interactionLevel.automatic;pp.printerName = \"Microsoft XPS Document Writer\";this.print(pp);");

Please feel free to contact us for any further assistance.


Best Regards,

Works great thank you.

One more question: Do you know howto set a printer name when it is a network printer:
I have a printer names ‘\my printer server\printer name’, but when i set this, it will fallback to the default printer.
I guess it’s related with the ‘’ in the name. I tried several different ways to set this name in code, but none worked.

thanks

Hi Manuel,

Thanks for your feedback. For setting network printer for printing, please check [this thread](https://forums.adobe.com/thread/760193?tstart=0), hopefully it will help you to accomplish the task.

Please feel free to contact us for any further assistance.

Best Regards,

Works.

Thanks for your support.

cheers

Hi Manuel,


Thanks for your feedback. It is good to know that you have manged to accomplish your requirements.

Please keep using our API and feel free to ask any question or concern, we will be more than happy to extend our support.

Best Regards,