Problem Printing use Esc/Pos command

2,989 views
Skip to first unread message

99

unread,
Aug 22, 2012, 11:31:34 AM8/22/12
to jzebra...@googlegroups.com
Dear all,

I have been failed so many times to use esc/pos command to set raw printing style.
I used esc commands based on  http://www.delfi.com/SupportDL/Epson/Manuals/TM-T88IV/Programming%20manual%20APG_1005_receipt.pdf
especially i need to use esc commands as follows
    ESC a : Select justification (center & right)
    ESC d : Print and feed n lines
    /t         : tab

but I do not understand why the esc command did not work, how to set n variable?
Could you please show me the right way?i would be glad if you can give me an example

this is my code before:
function print() {
         var applet = document.jZebra;
         if (applet != null) {
       
        applet.findPrinter("zebra");
        applet.append("\x1B\x40"); //reset printer
        applet.append(chr(27) + 'w1' + chr(27) + 'W1' + chr(27) + chr(69) + "company\r\n" + chr(27) + 'w0' + chr(27) + 'W0');//Format Bold on
        applet.append("address\r\n" + chr(27) + chr(70));//Format Bold off
        applet.append("Telp\r\n");
        applet.append("\n");      
        applet.append("Cashier '\r\n");
        applet.append("------------------------------------------\r\n");
        applet.append("Date\r\n");
        applet.append("Item \t Price \t Qty \t Disc \t Total \r\n");
        applet.append("---------------------------------------- \r\n");
                 
                           
        applet.append("------------------------------------------\r\n");
        applet.append(chr(27) + chr(97) + chr(2));//right alignment
        //applet.append(" SUB TOTAL : \t 3750\r\n");
        //applet.append("TAX   : \t 5000\r\n");
        applet.append(chr(27) + chr(69) + " TOTAL     : \t 5000\r\n" + chr(27) + chr(70));
        applet.append("CASH   : \t 5000\r\n");
        applet.append(" CHANGE   : \t 5000\r\n");
        applet.append(chr(27) + chr(97) + chr(1));//center alignment
        applet.append("-THANK YOU-\r\n");
        applet.append("\x1B\x40");
        applet.append(chr(27) + chr(100) + chr(5));//feed paper 5 lines
        applet.print();// Send characters/raw commands to printer
     }
     
     monitorPrinting();
      }
     

Regards,

Candra

capp...@yahoo.com

unread,
Aug 22, 2012, 11:56:52 AM8/22/12
to jzebra...@googlegroups.com
Hello,

For centering, try:

 applet.append(chr(27) + chr(97) + chr(49));//center alignment  

chr(49) is actually 1 where as chr(1) is SOH.

Similar to the other functions that needs those "n" integers. Check ascii table here: http://www.asciitable.com/


Regards,
Bahadir



From: 99 <candra.9...@gmail.com>
To: jzebra...@googlegroups.com
Sent: Wednesday, 22 August 2012, 18:31
Subject: [jZebra] Problem Printing use Esc/Pos command

--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra


99

unread,
Aug 22, 2012, 8:57:52 PM8/22/12
to jzebra...@googlegroups.com
Dear Bahadir,

Thank you for your responce.
I have tried to change:


function print() {
         var applet = document.jZebra;
         if (applet != null) {
       
        applet.findPrinter("zebra");
        applet.append(chr(27) + chr(97) + chr(49));//center alignment
        applet.append("-THANK YOU-\r\n");
        applet.append("\x1B\x40");
        applet.print();// Send characters/raw commands to printer
     }
     
     monitorPrinting();
      }

and it did not work :(

regards,

Candra

Tres Finocchiaro

unread,
Aug 23, 2012, 10:23:03 PM8/23/12
to jzebra...@googlegroups.com
I cannot provide ESCP help in this case, but I'd like to add that "ESC a" can be represented as:

"\x1B" + "a"

or

"\x1Ba"

or

String.fromCharCode(27) + "a".

The CharCode or the Hex is only needed when it's a special character.

Eko is also a great resource on this topic, he wrote "directprint" for these ESC/P difficulties. Perhaps it can help?  



-Tres

--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra

capp...@yahoo.com

unread,
Aug 23, 2012, 10:23:43 PM8/23/12
to jzebra...@googlegroups.com
Hello Candra,

I have just tested it with my good old TM-T70 and the following command is outputting this.

applet.append("\x1B\x40");
applet.append("\x1B\x61\x31");//center alignment 
applet.append("-THANK YOU-\r\n"); 
applet.append("-TEXT TEXT TEXT-\r\n"); 
applet.append("-XXXXXXXXXXXXXX-\r\n"); 
applet.append("\x1D\x56\x41");//cut

If this doesn't work, I suggest trying the printers own driver instead of a generic driver.
Check the following documentation if you haven't seen it before.


P.S: Sorry for the late response, though I have sent this yesterday, seems google-groups rejected my email with an attachment.

Regards,
Bahadir

Sent: Thursday, 23 August 2012, 3:57
Subject: [jZebra] Re: Problem Printing use Esc/Pos command

        applet.append("--------------- ---------------------------\r\ n");
        applet.append("Date\r\n");
        applet.append("Item \t Price \t Qty \t Disc \t Total \r\n");
        applet.append("--------------- ------------------------- \r\n");
                 
                           
        applet.append("--------------- ---------------------------\r\ n");
        applet.append(chr(27) + chr(97) + chr(2));//right alignment
        //applet.append(" SUB TOTAL : \t 3750\r\n");
        //applet.append("TAX   : \t 5000\r\n");
        applet.append(chr(27) + chr(69) + " TOTAL     : \t 5000\r\n" + chr(27) + chr(70));
        applet.append("CASH   : \t 5000\r\n");
        applet.append(" CHANGE   : \t 5000\r\n");
        applet.append(chr(27) + chr(97) + chr(1));//center alignment
        applet.append("-THANK YOU-\r\n");
        applet.append("\x1B\x40");
        applet.append(chr(27) + chr(100) + chr(5));//feed paper 5 lines
        applet.print();// Send characters/raw commands to printer
     }
     
     monitorPrinting();
      }
     

Regards,

Candra

capp...@yahoo.com

unread,
Aug 22, 2012, 9:46:25 PM8/22/12
to jzebra...@googlegroups.com
Hello Candra,

I have just tested it with my good old TM-T70 and the following command is outputting the attached image.

applet.append("\x1B\x40");
applet.append("\x1B\x61\x31");//center alignment 
applet.append("-THANK YOU-\r\n"); 
applet.append("-TEXT TEXT TEXT-\r\n"); 
applet.append("-XXXXXXXXXXXXXX-\r\n"); 
applet.append("\x1D\x56\x41");//cut

If this doesn't work, I suggest trying the printers own driver instead of a generic driver.
Check the following documentation if you haven't seen it before.


Regards,
Bahadir


From: 99 <candra.9...@gmail.com>
To: jzebra...@googlegroups.com
Sent: Thursday, 23 August 2012, 3:57
Subject: [jZebra] Re: Problem Printing use Esc/Pos command

        applet.append("--------------- ---------------------------\r\ n");
        applet.append("Date\r\n");
        applet.append("Item \t Price \t Qty \t Disc \t Total \r\n");
        applet.append("--------------- ------------------------- \r\n");
                 
                           
        applet.append("--------------- ---------------------------\r\ n");
        applet.append(chr(27) + chr(97) + chr(2));//right alignment
        //applet.append(" SUB TOTAL : \t 3750\r\n");
        //applet.append("TAX   : \t 5000\r\n");
        applet.append(chr(27) + chr(69) + " TOTAL     : \t 5000\r\n" + chr(27) + chr(70));
        applet.append("CASH   : \t 5000\r\n");
        applet.append(" CHANGE   : \t 5000\r\n");
        applet.append(chr(27) + chr(97) + chr(1));//center alignment
        applet.append("-THANK YOU-\r\n");
        applet.append("\x1B\x40");
        applet.append(chr(27) + chr(100) + chr(5));//feed paper 5 lines
        applet.print();// Send characters/raw commands to printer
     }
     
     monitorPrinting();
      }
     

Regards,

Candra
photo.JPG
Reply all
Reply to author
Forward
0 new messages