[英]How can i set the print position of an image JavaPOS
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. 我一直在使用printBitmap方法在热敏收据上打印图像,我可以将图像居中或向左或向右对齐,但是我无法确定图像的打印位置(始终打印在收据的顶部)知道是否可以设置坐标以在所需位置打印图像。 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. POS打印机在线打印。 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. 此示例方法将打印文本,输入3行,然后打印徽标,然后在徽标下方打印文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.