java javax.print.PrintException:打印机不接受作业

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4547411/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 06:54:10  来源:igfitidea点击:

javax.print.PrintException: Printer is not accepting job

javaprinting

提问by Ajith Jose

I am getting the "javax.print.PrintException: Printer is not accepting job.", when I try to execute

我得到 " javax.print.PrintException: Printer is not accepting job.", 当我尝试执行

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

我看到此问题发生在一台机器打印到打印机上,但另一台机器能够使用相同的 API 调用打印到同一台打印机。我正在查看来自 Oracle Sun 的错误报告,解释了下面粘贴的类似问题。 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.

但是那里提到的解决方法都没有为我解决问题。任何帮助表示赞赏。

采纳答案by Ajith Jose

Removing and adding the printer fixes the problem as mentioned in the bug as a workaround. It worked for me.

作为解决方法,删除和添加打印机修复了错误中提到的问题。它对我有用。

回答by Vikram

printerName=printerName.replaceAll("#", "\\");

打印机名称=打印机名称.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.

不要使用默认打印机,如果打印机是默认打印机,则将“#”替换为“//”。由于窗口系统我得到了这个异常,我使用上面的代码替换了我的打印机名称,我的问题现在解决了。

回答by JoshDM

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.

虽然这不会解决报告的问题(其中一台打印机正常工作而另一台出现故障),但如果打印机由于系统问题(例如打印机的碳粉用完)而变得不可用,则会报告此错误。在这种情况下,更换碳粉应该可以解决问题。