Forum Moderators: coopster

Message Too Old, No Replies

Can I send printer codes from web page?

esc codes in a print document

         

salewit

7:18 am on Jan 3, 2011 (gmt 0)

10+ Year Member



Something tells me this isn't possible. I am working on a script that prints two documents back to back onto a receipt printer from a webpage, and want to issue a "receipt cut" command in between printing these pages. The command is ESC d 1 or decimal 27, 100, 49. Maybe with javascript?

Readie

3:04 pm on Jan 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



JavaScript can detect key presses - you'll need to Google the specifics of it.

Anyway, if the key combination you mentioned above is pressed, you could set some boolean variable to false, and just check this variable before the second print function runs.

rainborick

3:24 pm on Jan 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You could try embedding an HTML entity sequence in a span or div that is "visible" only when media="print.

<style media="screen">
.receiptCut { display:none; }
</style>
<style media="print">
.receiptCut { display:normal; }
</style>
.
.
.
<span class="receiptCut">&#27;d1</span>

rainborick

3:27 pm on Jan 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Sorry... dec2hex on my first cup of coffee Monday morning...

<span class="receiptCut">&#1b;d1</span>


How and when you embed that into your JavaScript is up to you.