I want to print a bitmap logo file with ESC POS command ESC*. Following is the link for technical documentation of the command.
https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=88
According to me, the printer requires the image data in the form of 1s and 0s. So, it prints a dot, with the occurrence of 1 and blank, with the occurrence of 0. But I am not able to figure out how to send multi line bit image data with the help of above command, since the command accepts only the image data in the horizontal direction. Please help me with the problem.
ESC *
is one of several "bit image" commands in ESC/POS. It accepts "column format" data, which can only represent a single line of either 8 or 24 pixels. So there are two good options here.
ESC *
It sounds like you are able to print one line, so I will assume that the data format itself is not an issue.
You can print multiple lines by simply repeating the command to print the extra lines, separated by line breaks \n
. This requires chopping up the image, and padding it with whitespace so that it is a multiple of 8 or 24 pixels in height (again, due to the format).
Because of line spacing, you need to issue a command to change the size of line feeds during the image print, then another command to reset them at the end.
I use ESC 3 0x10
for 16-unit line feeds (bytes 0x1b 0x33 0x10
) and ESC 2
(bytes 0x1b 0x32
) to reset.
ESC *
ESC *
This method of printing has excellent compatibility with old printers, but you can get some thin horizontal lines in the output.
GS v 0
This bit image command accepts the different "raster format" data. I make use of the fact that the blob in this format is identical to the binary data in the widely implemented PBM bitmap format (specifically the binary data in files with the P4 header).
The height of the image will be limited by your print buffer size, but could go up to 65535
pixels. The width must be divisible by 8 because of the representation.
VS v 0
GS v 0
Side note: These snippets the actual prototypes of the image processing code that now appears in the popular open source escpos-php and python-escpos libraries. Using an existing library has a number of benefits, and you should consider it if it's an option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With