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.
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);