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);
}
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.