I am using Apache wicket 6.19.0
, pdfbox 1.8.8
, and Java 8
.
The problem I am facing is I get the print dialog on screen when I deploy my application on a Windows
machine, but when deployed on the Linux
server it doesn't show the print dialog on screen when invoked the print functionality from UI.
Code:
public static PrintService choosePrinter() {
PrinterJob printJob = PrinterJob.getPrinterJob();
if(printJob.printDialog()) {
return printJob.getPrintService();
}else {
return null;
}
}
@Override
public File getObject() {
File file = new File("document.pdf");
file.deleteOnExit();
PDDocument document = new PDDocument();
//prepare the pdf here...
PrinterJob job = PrinterJob.getPrinterJob();
PrintService service = choosePrinter();
if(service != null){
job.setPrintService(service);
document.silentPrint(job);
}
document.close();
} catch (Exception e) {
LOGGER.error("Exception: "+e);
}
return file;
}