问题描述
因此,我正在尝试使用Java代码将使用.PNG图像文件的标签直接打印到Zebra打印机(ZP 450-200dpi)。当我这样做时,我可以看到打印机队列显示“正在打印...”,然后它消失了,但没有任何打印内容。我想知道是否将PNG直接打印到Zebra打印机,这是否是正常行为,或者我的代码做错了什么?打印机仅支持ZPL字符串吗?
这是一段代码-
PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob job=ps.createPrintJob();
job.addPrintJobListener(new PrintJobAdapter() {
public void printDataTransferCompleted(PrintJobEvent event){
JOptionPane.showMessageDialog(null,"Print Complete","InfoBox: " + "Progress",JOptionPane.ERROR_MESSAGE);
}
public void printJobNoMoreEvents(PrintJobEvent event){
JOptionPane.showMessageDialog(null,"No More Events",JOptionPane.ERROR_MESSAGE);
}
});
FileInputStream fis;
try {
fis = new FileInputStream("C:\\temp\\my_image.png");
Doc doc=new SimpleDoc(fis,DocFlavor.INPUT_STREAM.AUTOSENSE,null);
PrintRequestAttributeSet attrib=new HashPrintRequestAttributeSet();
attrib.add(new copies(1));
job.print(doc,attrib);
} catch (FileNotFoundException | PrintException e1) {
// Todo Auto-generated catch block
e1.printstacktrace();
}
这是打印机队列的快照-
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)