1

I bought a cheap thermal receipt printer for some practice (Amazon B07848ZBXT). It seems to try to adhere to the ESC/POS standard.

As best I can tell it has 2 fonts controlled by bytes {27, 77, 0} and {27, 77, 1}, the latter being a smaller font. However when I'm using the smaller font, $ prints as ¥ (see demo print). Their own Amazon image has this also. Would there be a way to say stop replacing character codes or is this a 'low level' replacement that probably can't be overridden?

For my code I'm using Java. I store everything in String and get a byte array at the end and print it via javax.print. A sample is below.

Picture of receipt where $ is shown in bigger font but ¥ appears in the smaller font

final byte[] Init = {27, 64};
String stringToPrint= new String(Init);

byte[] feedStart = {27,101,(byte)2};  //(Side note, is there someway to combine the byte[] initialization and the String() usage?)
stringToPrint += new String(feedStart);
stringToPrint += "My text";

byte[] feed = {27,101,(byte)1};
stringToPrint += new String(feed );

byte[] feedAndCut = {29, 'V', 66, 0};
stringToPrint += new String(feedAndCut );

byte[] byteArray = stringToPrint.getBytes();

AttributeSet attrSet = new HashPrintServiceAttributeSet(new PrinterName(PRINTER_NAME, null));
DocPrintJob job = PrintServiceLookup.lookupPrintServices(null, attrSet)[0].createPrintJob();

DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
Doc doc = new SimpleDoc(byteArray, flavor, null);
PrintJobWatcher pjDone = new PrintJobWatcher(job);

job.print(doc, null);
CeePlusPlus
  • 803
  • 1
  • 7
  • 26
  • 1
    Do what Hiran Chaudhuri said - you absolutely need to find the manual! ADDITIONAL NOTES: 1) you apparently have a "Terow XP-58 Thermal Receipt Printer". 2) Per a .pdf I found from a Google search: "ESC/POS compatible; setting DIP switch to choose characters and fonts", and "Support international languages". Good luck! – paulsm4 Jul 13 '22 at 20:24

1 Answers1

1

It's been a long time, but...

You can run the printer in graphics mode where you control each and every dot. And you can run it in text mode where you send characters and the printer needs to know how to print them. I guess you are using text mode currently.

Very likely you just need to configure the charset/codepage for your printer to match your Java program's output. From what you state the printer may be set to some Japanese charset. Grab the vendor's manual to see how it is configured.

Queeg
  • 7,748
  • 1
  • 16
  • 42
  • Since the target character is Chinese yuan, it will be an international character setting of Chinese instead of Japanese. See this article. [International Character Sets](https://reference.epson-biz.com/modules/ref_charcode_en/index.php?content_id=3), [ESC R](https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=29) – kunif Jul 14 '22 at 01:07