我正面临 java.awt.print.PrinterException: Printer is not accepting job.. 发送文档以动态打印时我的 jsp 页面中出现异常......
String pdfFile = "D://Records.pdf";
boolean silentPrint = false;
String printerindx = "1";
String password = "";
PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
if (pdfFile == null) {
System.out.println("No PDF file available");
}
PDDocument document = null;
try {
document = PDDocument.load(pdfFile);
if (document.isEncrypted()) {
document.decrypt(password);
}
PrinterJob printJob = PrinterJob.getPrinterJob();
if (printerindx != null) {
PrintService[] printServices = PrinterJob.lookupPrintServices();
for (PrintService printService : printServices) {
if (printService.getName().equals("HP LaserJet P1007") {
System.out.println("Printer found ....");
printJob.setPrintService(printService);
System.out.println(printService);
}
}
}
document.print(printJob);
} finally {
if (document != null) {
document.close();
}
}
System.out.println("Printing Completed...");
怎么了?