What i have so far is the following code:
FileInputStream fin =new FileInputStream(filename);
DocFlavor df = DocFlavor.INPUT_STREAM.AUTOSENSE;
Doc d = new SimpleDoc(fin, df, null);
PrintService P = PrintServiceLookup.lookupDefaultPrintService();
if (P != null) {
DocPrintJob job = P.createPrintJob();
job.print(d, null);
}
fin.close;
the code is working fine but the printer does’t interpret the commands if the file containing commands, it keep printing the exact string content of the file.
so how to send command to Epson receipt printer ?
As have been figured out that commands may have to be send directly not in ESC/POS format but you need to interpret the code to hexadecimal in you java code and send to printer as the way i post, whether from a file or string.
as example instead of initializing the Epson receipt printer by:
and to cut the paper in receipt printer the code may be:
so this is how it works for me.
instead of
use
however it maybe a way to send code as its command format but desperately could’t do that so far. and not sure if it can done from java.