我正在尝试打印PDF文档。
我可以在打印机队列中看到作业,然后看到它消失,就像打印机已完成作业一样。PDF Java打印:在打印机作业队列中发送的作业,但没有打印
但问题是没有打印。 我找不出在我的代码中有什么问题。
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null,null);
PrintService service = null;
for (String imprimante : listImprimantes){
for(PrintService printService : printServices) {
Attribute[] attrs = printService.getAttributes().toArray();
for (int j=0; j<attrs.length; j++) {
String attrName = attrs[j].getName();
String attrValue = attrs[j].toString();
if (attrName.equals("printer-info")){
if (attrValue.equals(imprimante)){
service = printService;
DocFlavor[] flavors = service.getSupportedDocFlavors();
break;
}
}
}
}
}
InputStream fi = new ByteArrayInputStream(baos.toByteArray());
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
DocPrintJob printJob = service.createPrintJob();
Doc doc = new SimpleDoc(fi, flavor, null);
try {
if (doc != null) {
printJob.print(doc, null);
}
}
catch (PrintException e1) {
log.debug(e1.getMessage());
}
如果有人可以帮助我在此...
你有没有想过这个?我有同样的问题... –
不,我没有。问题仍在进行中 – user1260928