问题
I am getting the "javax.print.PrintException: Printer is not accepting job."
, when I try to execute
printService.createPrintJob().print(
new SimpleDoc(this,
DocFlavor.SERVICE_FORMATTED.PRINTABLE,
docAttributeSet),
printRequestAttributeSet);
I am seeing this problem happening for one machine printing to the printer but the other machine is able to print to the same printer using the same API call. I was looking at bug report from Oracle Sun explaining similar problem which is pasted below. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6525150
But none of the workarounds mentioned there is fixing the problem for me. Any help is appreciated.
回答1:
Removing and adding the printer fixes the problem as mentioned in the bug as a workaround. It worked for me.
回答2:
printerName=printerName.replaceAll("#", "\\");
don't use the default printer and if the printer is default one then replace '#' with '//'. Due to window system I got this exception, I have replaced my printer name by using the above code and my problem is now solved.
回答3:
While this won't resolve the reported issue (where one printer works and the other fails), this error can be reported if the printer becomes unavailable due to a systemic issue, such as if the printer runs out of toner. In this event, changing the toner should solve it.
来源:https://stackoverflow.com/questions/4547411/javax-print-printexception-printer-is-not-accepting-job