How can i set the print position of an image JavaPOS

512 views Asked by At

Good day.

I been using the printBitmap method to print an image on a thermal receipt, I can center or align the image to the left or right , but I cannot decide where the image is printing (it always print on the top of the receipt) I wanna know if there is possible to set the coordinates to print the image where I want. Thanks in advance any help you can give me. Here is the segment of the code that handle the image print:

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);
    }
}
1

There are 1 answers

0
Aaron Sanders On

POS Printer printing is in-line. For example,

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.");
}

This example method will print text, feed 3 lines and then print the logo, and then print text below the logo.