esc2html
converts an ESC/POS binary file into a HTML document. It is currently capable of rendering some types of
formatting and images, plus any ASCII text in the input file.
$ php esc2html.php receipt-with-logo.bin > output.html
This utility is included with escpos-tools. See the escpos-tools documentation for installation instructions.
php esc2html FILE
$ php esc2html.php receipt-with-logo.bin > receipt-with-logo.html
The HTML representation of the receipt is saved to a new file, and appears as:
The same binary data, when sent to a printer, renders as below:
$ cat receipt-with-logo.bin > /dev/usb/lp0
The input file used as an example here was generated by escpos-php, and is available here.
This utility will create a formatted HTML file. This can be converted accurately to PDF
via wkhtmltopdf
, where formatted plaintext can be subsequently extracted via
pdftotext -f -nopagebrk
, or images can be extracted via pdfimages
. If some text
is embedded in the finished document as an image, then pdfsandwich
can apply optical
character recognition to this.
Alternatively, the HTML may be converted accurately to a raster image via wkhtmltoimage
.
The correct layout of the HTML document partially depends on the use of CSS3, so the
use of document converters such as unoconv
and pandoc
tends to lose some information.
These can can be used to produce RTF, DOC, and some other formats if the lossy conversion is acceptable.