Java printjob 在 Eclipse 中运行,但是当我们将应用程序转换为 exe 时,除了 PrintJob 之外,一切正常。有人可以支持我吗?注意:使用 Windows 7
public static void print() {
PdfDocument pdf = new PdfDocument();
pdf.loadFromFile("C:\\Mayura\\KFF Titrator Report.pdf");
PrinterJob loPrinterJob = PrinterJob.getPrinterJob();
PageFormat loPageFormat = loPrinterJob.defaultPage();
Paper loPaper = loPageFormat.getPaper();
//remove the default printing margins
loPaper.setImageableArea(0,0,loPageFormat.getWidth(),loPageFormat.getHeight());
loPageFormat.setPaper(loPaper);
loPrinterJob.setPrintable(pdf,loPageFormat);
//display the print dialog
if (loPrinterJob.printDialog()) {
try {
loPrinterJob.print();
} catch (PrinterException e) {
e.printStackTrace();
}
}
}