Java 文本大小爱普生TM-H5000II
我正试图减少文本的大小,根据我需要使用ESC的手册!1()但我不知道如何将其传递给java代码,我尝试定义一个位并使用十进制、十六进制和ASCII,但不起作用Java 文本大小爱普生TM-H5000II,java,epson,escpos,Java,Epson,Escpos,我正试图减少文本的大小,根据我需要使用ESC的手册!1()但我不知道如何将其传递给java代码,我尝试定义一个位并使用十进制、十六进制和ASCII,但不起作用 public class JavaPrinter implements PrinterApi { private Logger logger = LogManager.getLogger(JavaPrinter.class); PrintService printService; boolean isFile = false; Stri
public class JavaPrinter implements PrinterApi {
private Logger logger = LogManager.getLogger(JavaPrinter.class);
PrintService printService;
boolean isFile = false;
String printerName = null;
PrintStream prnStr;
private PipedInputStream pipe;
PipedOutputStream dataOutput;
Doc mydoc;
byte[] widthNormal = { 0x1b, '!', '1' };
@Override
public void setNormal() {
if (isFile)
return;
try {
prnStr.write(widthNormal);
} catch (IOException e) {
throw new DeviceServerRuntimeException("", e);
}
}
以上是我写的部分代码,谢谢大家的建议,帮助!THX您需要使用
1
作为带有ESC的数字代码>在ESC/POS中从大字体A更改为小字体B的命令
您还需要在后面添加一些文本和换行符,这在您的示例中是看不到的。一个自包含的Java示例如下所示:
import java.io.FileOutputStream;
import java.io.IOException;
class FontChangeDemo {
public static void main(String[] argv) throws IOException {
byte[] reset = {0x1b, '@'};
byte[] fontA = {0x1b, '!', 0x00};
byte[] fontB = {0x1b, '!', 0x01};
try(FileOutputStream outp = new FileOutputStream("/dev/usb/lp0")) {
outp.write(reset);
outp.write("Font A\n".getBytes());
outp.write(fontB);
outp.write("Font B\n".getBytes());
outp.write(fontA);
outp.write("Font A again\n".getBytes());
}
}
}
在TM-T20II上显示:
这假设您的设置在其他方面正常工作,并且能够将二进制数据传送到打印机。您的代码不是您所描述问题的最简单的工作示例,即格式未应用于文本(downvote不是我提供的,但是合理的)。对于您的回答,为什么/n很重要?我尝试使用您的代码,以及我在其他问题中找到的一些其他代码,如果没有/n,则无法工作