java使用参数ESC/POS热敏打印机发送命令
我的Java ESC/POS热敏打印机打印命令有问题。 我可以打印文本,但当我尝试执行POS命令时,它们不会运行
目前,我尝试执行的命令是“esc3n”,其中我将n定义为行距
当前代码:
printHorizontalLine();
byte[] line = {ESC, (byte)'3', 5};
printBytes(line);
printHorizontalLine();
public void printBytes(byte[] bytes) {
String printer = printerName;
/* Finding the printer of name printer */
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, pras);
PrintService service = findPrintService(printer, services);
DocPrintJob job = service.createPrintJob();
// Possible umlaut characters:
try {
Doc doc = new SimpleDoc(bytes, flavor, null);
job.print(doc, null);
} catch (PrintException e) {
// Print had a problem
e.printStackTrace();
}
}
我试图将两条水平线(我可以打印的两个文本)的距离减少到5,而不是默认的31。问题是:没有区别
我希望两条线彼此更近些
共 (0) 个答案