I am facing java.awt.print.PrinterException: Printer is not accepting job..Exception in my jsp page when sending documents to print dyanamically................
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...");
whats going wrong ?