工作了7天后,我得到了正确的方法来获取打印件,然后用裁纸器裁切该收据。ESC命令对于获取打印以及与打印机有关的其他任务非常重要。我们必须将这些ESC
CMD以字节数组的形式传递给行式打印机。
有一些命令如下
ESC FF DataPrint,[pre] <1B>H<OC>H,[Function] Print all the data in the print area collectively.
因此,只需创建此命令的字节数组,然后将其传递给打印机即可。
e.g. byte[] print = {0x1b,0x0c};现在将其传递给打印机。必须有一些方法,如getCmd()或writeCmd()等,具体取决于打印机。
我们如何通过编程在android中执行这些ESC命令?下面是执行此操作的代码
BuildinEx840 lpd=new BuildinEx840(); lpd.setMulticharMode(LinePrinterDevicebase.CHARACTERSET_USA);//initialise Cutter lpd.initCutter(); LinePrinter lp=new LinePrinter(); lp.open(lpd); lpd.open(); try{ lpd.init(); }catch(IOException e){ e.printStackTrace(); } for(int i=0; i<5;i++){ lp.printNormal("Testing the Line Printer"); } int totalLinefeed=listofItemList.size();//ESC CMD for line feeds byte[] lfs=new byte[]{0x1B,'d', 5}; sendtoExprinter(lpd,lfs);//ESC CMD for paper cut lfs=new byte[]{0x1B,'i'}; sendtoExprinter(lpd, lfs);private void sendtoExprinter(BuildinEx840 dev, byte[] instr) { try{ dev.write(instr); }catch(IOException e){ e.printStackTrace(); } }更新: 通过热敏打印机打印图像
在某些打印机中,您可以在打印机的非易失性存储器中定义图像,然后通过 ESC cmd 1C 70 01 30
从那里打印图像。在其他一些打印机中,您可以在通过热敏打印机打印图像时给出图像的直接路径。
在任何行式打印机中,我们都必须通过此打印机传递ESC CMDObj.write(command);
方式。我要感谢SO社区,也要特别感谢TheBlastOne,他为我提供了正确的指导。
如果有人在集成热敏打印机方面遇到任何问题,请随时询问。



