Skip to content

Latest commit

 

History

History
60 lines (39 loc) · 2.04 KB

esc2html.md

File metadata and controls

60 lines (39 loc) · 2.04 KB

esc2html

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

Installation

This utility is included with escpos-tools. See the escpos-tools documentation for installation instructions.

Usage

php esc2html FILE

Example

$ 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:

receipt-with-logo-img.png

The same binary data, when sent to a printer, renders as below:

$ cat receipt-with-logo.bin > /dev/usb/lp0

receipt-with-logo-small.png

The input file used as an example here was generated by escpos-php, and is available here.

Further conversions

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.

See also