1

抱歉,如果这将被视为与我之前的问题的重复,但是...我正在尝试使用 ESCPOS 命令发送打印机以写入图像行,然后是剪切纸(部分剪切)命令,并在结果我收到缺少图像行(此时我尝试了两台不同的打印机,其中一台随机跳过图像行,另一台静态地执行此操作)。

整个图像打印场景取自new-grumpy-mentat,稍作改动:

                for (int y = 0; y < image.length; y += 24) {
//This part
                    if (n == 2) {
                        bos.write(printerSchema.getCutPaper());
                    }
// END
                        bos.write(printerSchema.getImageMode());
                        // Set nL and nH based on the width of the image
                        bos.write(new byte[] { (byte) (0x00ff & image[y].length), (byte) ((0xff00 & image[y].length) >> 8) });
                        for (int x = 0; x < image[y].length; x++) {
                            // for each stripe, recollect 3 bytes (3 bytes = 24 bits)
                            bos.write(recollectSlice(y, x, image));
                        }

                    // Do a line feed, if not the printing will resume on the same
                    // line
                    bos.write(printerSchema.getLineFeed());
                    n++;
                }

我认为在剪切操作可能进行之前,必须对要绘制的图像线进行最终确定操作,但找不到任何东西。命令:

IMAGE_MODE = new byte[] { 0x1B, 0x2A, 33 }, 
LINE_FEED = new byte[] { 0x0A },
LINE_SPACE_24 = new byte[] { 0x1B, 0x33, 24 }, 
LINE_SPACE_30 = new byte[] { 0x1B, 0x33, 30 },
CUT_PAPER = new byte[] { 29, 86, 1 };
4

0 回答 0