Request for printing ESCPOS codes directly to Generic/Text printer ( Whole POS Industry use ESCPOS)
Reported by
tjunus...@gmail.com,
Sep 13 2017
|
|||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36 Steps to reproduce the problem: 1. Install Generic/Text printer and point driver to TCP/IP address of any thermal printer ( ex EPSON TM-88i) 2. Run script below 3. Select the Generic/Text printer (1) What is the expected behavior? Formatted text is printed by the thermal printer ( - bold, align, empazized text, barcode, qr code, images etc ) What went wrong? Chrome does not support direct printing of ASCI text to a printer. IE, EDGE and FF do. The code below runs perfectly in IE, EDGE and FF but not in Chrome. Did this work before? N/A Does this work in other browsers? N/A Chrome version: 60.0.3112.113 Channel: n/a OS Version: 10.0 Flash Version: This issue linked directly to this https://bugs.chromium.org/p/chromium/issues/detail?id=734850 issue ( if ZPL codes allowed to be printed then ESCPOS will also be printed ), and another Chrome App project uses ESCPOS https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/usb-label-printer ( https://github.com/GoogleChrome/chrome-app-samples/blob/master/samples/usb-label-printer/index.js ) CAN CHROME PLEASE ADD A FEATURE TO PRINT ESCPOS DIRECTLY? ESCPOS IS USED BY 1.000.000+ RECEIPT THERMAL PRINTERS IN Point-of-Sale(POS) INDUSTRY, ALL OVER THE WORLD. ESCPOS stands for Epson's ESC/POS protocol for thermal receipt printers. It allows you to generate and print receipts with basic formatting, cutting, and barcodes on a compatible thermal printer. Following to this author ( https://mike42.me/blog/what-is-escpos-and-how-do-i-use-it ) i did this example below. HERE IS EXAMPLE OF SIMPLE JAVASCRIPT CODE THAT WORKS PERFECTLY IN IE, EDGE AND FF. BUT NOT IN CHROME..... ========================================== JSFiddle - https://jsfiddle.net/y2sxuwfr/2/ ( document.write not allowed ) <!doctype html> <html lang="en"> <head> <title>Print ESCPOS from browser</title> <style> @import url('http://azalea.com/web-fonts/Code39Azalea.min.css'); body { font-family: monospace; width:880px;} pre, code { border:1px solid #aaa; width: 400px; height:400px; float:left; margin:0 5px 0 0; padding: 5px; } .clear { clear: both; } barcode { font-family:Code39AzaleaFont; font-size:50px; } </style> </head> <body> <h1>Test page for print ESCPOS from browser!</h1> <script type="text/javascript"> var $ = function(id) { return document.getElementById(id); }; function printEscposCode(escpos) { console.log(escpos); // evaluating for demo, getting codes from pre tag eval(escpos); console.log(msg); var printWindow = window.open(); printWindow.document.open('text/plain') printWindow.document.write(msg); printWindow.document.close(); printWindow.focus(); printWindow.print(); printWindow.close(); } function chr(code) { return String.fromCharCode(code); } </script> <input type="button" value="Print escpos" onclick="printEscposCode($('escpos').innerHTML)" /> <br/> <br/> <pre id="escpos"> /* ASCII constants */ var ESC = "\x1b"; var GS="\x1d"; var NUL="\x00"; var msg = ""; /* Output an example receipt */ msg += ESC+"@"; // Reset to defaults msg += ESC+"E"+chr(1); // Bold msg += "FOO CORP Ltd.\n"; // Company msg += ESC+"E"+chr(0); // Not Bold msg += ESC+"d"+chr(1); // Blank line msg += "Receipt for whatever\n"; // Print text msg += ESC+"d"+chr(4); // 4 Blank lines /* Bar-code at the end */ msg += ESC+"a"+chr(1); // Centered printing msg += GS+"k"+chr(4)+"987654321"+NUL; // Print barcode msg += ESC+"d"+chr(1); // Blank line msg += "987654321\n"; // Print number msg += GS+"V\x41"+chr(3); // Cut </pre> <code class="sample"> FOO CORP Ltd. <br/> Receipt for whatever <br/> <br/> <br/> <br/> <barcode>987654321</barcode> </code> <br class="clear"/> <p>Use the build in windows [Generic / Text Only] driver for your thermal printer. Instead of the EPSON driver. </p> <p>Tested in: <b>Edge, Internet Explorer, Firefox</b></p> <p>Not working in: Chrome (Chrome prints as image and not in text)</p> </body> </html> ========================================== Procedure: 1 - Install in Windows a GENERIC / TEXT PRINTER DRIVER 2 - Point this Driver to TCP/IP adres of your any ESCPOS compatible thermal printer ( ex EPSON TV-80i ) 3 - Now in IE, EDGE and FF, you can print ESCPOS codes to your EPSON printer with code above. BUT NOT IN CHROME....
,
Sep 13 2017
From looking at the preview, this will require a much more involved solution than the ZPL request did since it appears we cannot render the commands to PDF the way we could the ASCII characters. The printing backend starts from the PDF in preview, so any information lost in the translation to PDF can't be retrieved without significant changes to the current printing architecture. Looping in Skia>PDF, because I think the options here are either: (1) Adding the ability to render these commands as text in the PDF (not sure if that is Blink, Skia, or just infeasible) and then fixing up/adding to the ZPL solution on the printing side if needed to output them correctly, or (2) Adding a Skia->Text converter and restructuring printing.
,
Sep 14 2017
,
Sep 12
Hello, any news on this important urgent matter? thanks in advance!
,
Sep 13
Is `var printWindow = window.open(); printWindow.document.open("text/plain");` even repecting the MIME type? It looks like we're loosing the newlines.
,
Sep 13
Attached simpler example.
,
Sep 14
rbpotter@chromium.org May be we could escape ASCII in preview, and after preview we unscape if it is Generic Text ? and pass some parameters to SKIA, unescape=true ?
,
Sep 14
Maybe bypass SkPDF completely for text/plain with ASCII control codes in it? |
|||
►
Sign in to add a comment |
|||
Comment 1 by ligim...@chromium.org
, Sep 13 2017Components: Internals>Printing