使用Java程序将二维码打印到打印机

问题描述

我正在尝试使用Java将二维码打印到TSC TE打印机。在Windows中打印后,打印机每次都跳过一个标签。如果我不使用程序直接打印,则打印正确。

在ubuntu中,打印机正在打印二维码,但是每次打印后红色指示灯都会闪烁。

请帮助我。

public class print {
    public static void main(String args[]){
        try{
            DocFlavor flavor = DocFlavor.INPUT_STREAM.PNG;
            PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
            aset.add(new PrinterResolution(203,203,PrinterResolution.DPI));
            aset.add(new MediaPrintableArea(5,1,MediaPrintableArea.MM));
            PrintService[] services = PrintServiceLookup.lookupPrintServices(null,null);
            for(PrintService printService : services) {
                if(printService.getName().equals("TSC_TE244")) {
                    DocPrintJob pj = printService.createPrintJob();
                    FileInputStream fis = new FileInputStream("/Users/user/sridhar/Desktop/qr.png");
                    Doc doc = new SimpleDoc(fis,flavor,null);
                    pj.print(doc,aset);
                }
            }
        }
        catch(Exception e){
            System.out.println(e);
        }
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...