Java PrintService 是否忽略 PrinterUri 属性?
我使用以下代码将打印作业发送到特定打印机:
PrintServiceAttributeSet aset = new HashPrintServiceAttributeSet();
try {
aset.add(new PrinterURI(new URI("ipp://hostName/printerName")));
} catch (URISyntaxException e) {
System.out.println("URI exception caught: "+e);
}
PrintService[] services =
PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.POSTSCRIPT,aset);
Strangley,我得到 9 个查找结果(=该特定主机上的所有可用打印机) - 而只有第一个结果是我正在寻找的结果。 我在 PrintService JavaDocs 和网络上进行了搜索,但没有发现任何关于此事的信息。
PrintServiceLookup 不是应该只返回符合我的请求的打印机吗? (在本例中 - 一台打印机)
提前致谢!
I'm using the following code in order to send a print job to a specific printer:
PrintServiceAttributeSet aset = new HashPrintServiceAttributeSet();
try {
aset.add(new PrinterURI(new URI("ipp://hostName/printerName")));
} catch (URISyntaxException e) {
System.out.println("URI exception caught: "+e);
}
PrintService[] services =
PrintServiceLookup.lookupPrintServices(DocFlavor.INPUT_STREAM.POSTSCRIPT,aset);
Strangley, I get 9 lookup results (=all available printers on that specific host) - while only the first result is the one I'm seeking.
I searched in the PrintService JavaDocs, and on the web - but found nothing on the matter.
Isn't PrintServiceLookup expected to return only the printers which match my request? (in this case - one printer)
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,我使用的 URI 是错误的(但语法有效,因此没有引发异常)。
因此,回答我最初的问题 - Java PrintService 忽略错误的属性(与我的预期相反,如果属性错误,PrintService 将不返回任何结果)。
无论如何,谢谢
It turns out that the URI I was using was wrong (yet with a valid syntax, so no exception was thrown).
So answering my initial question - Java PrintService ignores an attribute which is wrong (as opposed to my expectation, that PrintService would return no result in case of a wrong attribute).
Thanks anyway