Print a file pdf without open preview

I need to print a file pdf without open preview.
If I use this code :
var desktop = Packages.java.awt.Desktop;
if (desktop.isDesktopSupported()) {
desktop.getDesktop().print(“c:/temp/out.pdf”);
}

The file is printed on printer default system but I need to set the default printer.
Is it possibile to set the default printer?

If I use this code:
var _printerJob = Packages.java.awt.print.PrinterJob.getPrinterJob()
_printerJob.setJobName(“c:/temp/out.pdf”)
_printerJob.printDialog()
The file isn’t printed.
Does somebody know an alternalitive solution to print a pdf file in Servoy?
Thanks a lot!
Stefania

We are using apache pdfbox for this, _printer_name addresses the printer and _file_name is the file to be printed:

var _printerJob = Packages.java.awt.print.PrinterJob.getPrinterJob()
var _printServices = Packages.javax.print.PrintServiceLookup.lookupPrintServices(null, null)
for (var _i=0; _i<_printServices.length; _i++) {
	if (_printServices[_i].getName() == _printer_name) {
		_printerJob.setPrintService(_printServices[_i])
		break
	}
}
var _document = Packages.org.apache.pdfbox.pdmodel.PDDocument.load(_file_name)
_document.silentPrint(_printerJob)
_document.close()

We downloaded pdfbox.jar, fontbox.jar and jempbox.jar from http://pdfbox.apache.org and put these in the beans directory

I thank you very much for your help! Now it works :)

I downloaded pdfbox.jar, fontbox.jar and jempbox.jar from http://pdfbox.apache.org and put these in the beans directory but the application smart doesn’t work I have this error.
com.sun.deploy.net.JARSigningException: found a voice not signed in resource (Http:/localhost:8080/beans/fontbox.jar,1418315714352)
at com.sun.javaws,secutiry.SigningInfo.gtCommonCodeSignersForJar(Unknown Source)

How I can sign the beans in Server Servoy?
In the developer it works.
Thank Stefania

Help Please!
Thanks a lot

It looks like you need to code-sign the bean yourself. You can do that using the signtester tool.
Of course that requires that you have a code signing certificate,be it self-signed or one from a recognized signing authority.

Hope this helps.