0

再会。

我一直在使用 printBitmap 方法在热敏收据上打印图像,我可以将图像居中或对齐到左侧或右侧,但我无法确定图像的打印位置(它总是打印在收据的顶部)我想要知道是否可以设置坐标以在我想要的位置打印图像。在此先感谢您能给我的任何帮助。这是处理图像打印的代码段:

private void init() {
    if (ptr == null) {
    if (logger.isTraceEnabled()) {
        logger.trace("Init ptr=null portName=" + portName);
    ptr = new POSPrinter();
    try {
        ptr.open(portName);
        ptr.addStatusUpdateListener(this);
    } catch (JposException e) {
        ptr = null;
        throw new DeviceServerRuntimeException(ErrorCode.JPOS_PRINTER_ERROR, e);
    }
    if (logger.isTraceEnabled()) {
        logger.trace("Init  portName=" + portName);
    }
    }
}

public void printImage(String pathImage) {
    try {
        ptr.printBitmap(currentTargetDevice, pathImage, POSPrinterConst.PTR_BM_ASIS, POSPrinterConst.PTR_BM_CENTER);
    } catch (JposException e) {
        throw new DeviceServerRuntimeException(ErrorCode.JPOS_PRINTER_ERROR, e);
    }
}
4

1 回答 1

0

POS 打印机打印是在线的。例如,

private void printLogoTest(String pathImage){
    ptr.printNormal(POSPrinterConst.PTR_S_RECEIPT, 
              "Text at the above logo. \r\n \r\n \r\n");
    ptr.printBitmap(POSPrinterConst.PTR_S_RECEIPT,  
         pathImage,  
         POSPrinterConst.PTR_BM_ASIS, 
         POSPrinterConst.PTR_BC_CENTER);
    ptr.printNormal(POSPrinterConst.PTR_S_RECEIPT, 
               "Text at the above Below.");
}

此示例方法将打印文本,输入 3 行,然后打印徽标,然后在徽标下方打印文本。

于 2019-03-29T02:05:05.940 回答