Welcome to WebmasterWorld Guest from 54.196.104.66

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Can I send printer codes from web page?

esc codes in a print document

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

Junior Member

10+ Year Member

joined:June 12, 2004
posts: 119
votes: 0


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?
3:04 pm on Jan 3, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Dec 13, 2009
posts:945
votes: 0


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.
3:24 pm on Jan 3, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2003
posts:913
votes: 13


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>
3:27 pm on Jan 3, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2003
posts:913
votes: 13


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.