0

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);
    }
}
  • To get advice, please add details about the layout you want to print. – kunif Feb 26 '19 at 14:55
  • Hi, is a jpg image, i can print it, but not where i want, it always print on the top of the receipt. @kunif – Patricio Mora Feb 26 '19 at 15:28
  • Instead of repeating the question already written in the text, please add the example layout as a figure, then explain which position the text, and which position the image, you want to print. – kunif Feb 26 '19 at 22:32

1 Answers1

0

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.