How to print POS receipt invoice using jZebra

1,860 views
Skip to first unread message

Paresh Patel

unread,
Sep 2, 2014, 10:35:23 AM9/2/14
to jzebra...@googlegroups.com
Hi I am new to jZebra.

I need to print receipt invoice for POS kind store using through website.
I have attached here sample for POS receipt invoice to clear more.

I have done code using jZebra (ver. 1.8.7) to print POS receipt content using following code..
<div id="pagecontentdiv" style="padding:5px;">
  Logo
  POS items
  Payment details
  (all above with table tags)
</div>
<script>
if (isLoaded()) {
    // Searches for default printer
    qz.findPrinter();
 }
if (notReady()) { return; }
qz.setCopies(1);
var invoiceContent = document.getElementById("pagecontentdiv").innerHTML;
qz.appendHTML('<html><table face="monospace" border="1px"><tr height="6cm"><td>' + invoiceContent + '</td></tr></table></html>');
qz.printHTML();
</script>

I am trying to print in Zebra GC420d - http://www.zebra.com/id/zebra/na/en/index/barcode-printers/gc420d.html but could not print properly.

This printer description says ideal for Retail – price labeling and receipt printing

What I am missing here to print receipt invoice ?

Bill Image_Receipt.png
Message has been deleted

Paresh Patel

unread,
Sep 2, 2014, 10:40:55 AM9/2/14
to jzebra...@googlegroups.com
Please add button to print POS receipt example to current jZebra sample page and needed setting for it.

Tres Finocchiaro

unread,
Sep 2, 2014, 10:37:53 PM9/2/14
to jZebra users
> Please add button in jZebra sample page to print POS receipt kind invoice. 

There are examples. :)

Your printer seems to support ZPL and EPL natively.  Please use that rather than HTML.  Buttons for those technologies are already included in sample.html.

-Tres 

Paresh Patel

unread,
Sep 3, 2014, 10:05:59 AM9/3/14
to jzebra...@googlegroups.com
Thanks for the reply.

1) Can I test or see output of given examples without real printer attached e.g. ESCP button , EPL button ? Can i save output to PDF or text file ?
2) Client have machine EPSON TM88 , for that which printing language i should use to design receipt invoice ZPL,EPL, ESCP ?
3) Is there any sample or code snippet to design receipt invoice and PHP code snippet to build that receipt invoice ?

client have zdesigner printer and told on clicking
'Print ESCP' request gone in window print que but nothing print,
'Print EPL' seems to be stuck in que.  It Says "Printing", sucks about 2mm of paper back into the printer, then says "Restarting", then does again  over and over.
'Print ZPL' printed lable but disturbed printer functioning.

Please comment. I just need to print receipt invoice on EPSON TM 88 printer

Tres Finocchiaro

unread,
Sep 3, 2014, 12:17:54 PM9/3/14
to jZebra users
On Wed, Sep 3, 2014 at 10:05 AM, Paresh Patel <ppare...@gmail.com> wrote:
Thanks for the reply.

1) Can I test or see output of given examples without real printer attached e.g. ESCP button , EPL button ? Can i save output to PDF or text file ?
No.
 
2) Client have machine EPSON TM88 , for that which printing language i should use to design receipt invoice ZPL,EPL, ESCP ?
ESCP.

 
3) Is there any sample or code snippet to design receipt invoice and PHP code snippet to build that receipt invoice ?
No that I'm aware of.

 
client have zdesigner printer and told on clicking
Zdesigner is Zebra, not Epson so this is confusing.
 
'Print ESCP' request gone in window print que but nothing print,
'Print EPL' seems to be stuck in que.  It Says "Printing", sucks about 2mm of paper back into the printer, then says "Restarting", then does again  over and over.
'Print ZPL' printed lable but disturbed printer functioning.
Then adjust ZPL to your needs.
 
Please comment. I just need to print receipt invoice on EPSON TM 88 printer
Again, that contradicts your statement about using a Zebra printer.  The generally use completely different languages.  EPL and ZPL are what Zebra prefers usually.  ESCP is what Epson prefers usually.  Some printers implement each other's languages but you will need to read the specifications for your model hardware to be sure.

If you do not have the proper hardware, buy it.  If you are low on funds, get used hardware from ebay.

An Epson TM88V generally costs $300-$500 new.  I normally recommend getting the model with USB and Ethernet connectivity options.   Older models, such as the TM88III or TM88IV you can usually find on Ebay for much cheaper. Remember to order paper with it as well.

The Zebra GC420d is generally used for printing barcodes.  You would have to contact Zebra to find out if it is ideal for Point of Sales, but I am not familiar with people using this printer for Point of Sales and it does not list ESCP on its supported printing languages.

Learning a raw language such as EPL, ZPL, ESCP, etc can be very time consuming.  You may be able to subcontract a freelance worker to design and template the receipt for you.

-Tres

Tres Finocchiaro

unread,
Sep 3, 2014, 12:20:43 PM9/3/14
to jZebra users
>  Can i save output to PDF or text file ?

Well, technically yes you can save it to a text file, but it will be in its raw ZPL, EPL or ESCP format and won't necessarily be readable.  If you decide to do this anyway, just add a FILE: printer in your OS.  There are many tutorials on the internet for this.

Human eyes don't read raw languages very well, so ultimately you want the hardware.  If you know someone in the food or retail industry, they may have some ESCP compatible hardware you can borrow.


Paresh Patel

unread,
Sep 4, 2014, 10:36:32 AM9/4/14
to jzebra...@googlegroups.com
Thanks Tres for answering each questions and help me in understanding about raw printing.
About Printers Confusion was that I am developing printing receipt for a client who have EPSON printer but as i have no any such kind of printer I had asked someone else to test your sample link but he had tested in ZDesigner printer.
Sorry for this confusion because not cleared more.
Now i got that i have to build and design receipt invoice in ESCP printing language ( instead 'Print HTML' code which could not perfect understand by raw printer, right ? )

I am trying to print receipt with sample given in https://code.google.com/p/jzebra/wiki/ESCPCommands

Thanks for your help.

Tres Finocchiaro

unread,
Sep 4, 2014, 10:50:09 AM9/4/14
to jZebra users
> Now i got that i have to build and design receipt invoice in ESCP printing language ( instead 'Print HTML' code which could not perfect understand by raw printer, right ? ) 

Correct, for continuous feed printing, printHTML is not recommended.

That said, there are many people which use printHTML for receipts, but it uses Java's built-in HTML markup render which is terribly limited when compared to any web browser newer than Internet Explorer 2.

If you have small receipts of fixed size you may choose to use printHTML, or even use the HTML5 canvas functionality (print current page button), but when the receipts grow large in length, they overflow the standard page size and get cropped (we don't support continuous feed paper on HTML or HTML5 currently) so I generally recommend sticking with ESCP for point-of-sales type stuff.

If you happen to find a ESCP printer emulator for Windows, Linux or OSX please let us know.  We are asked about this quite often and it would make developing without hardware much easier.

Until you find one, you'll have to get the hardware.  Nearly every Point of Sales printer supports ESCP.  There are many cheap alternatives to Epson TM88 which you might find attractive for development, but expect a few compatibility issues with code if you go that path.

I am trying to print receipt with sample given in https://code.google.com/p/jzebra/wiki/ESCPCommands 

Great.  That was written by a community member.  Once you start writing your ESCP and need help with that, there are a few community members you will find helpful (as well as searching the internet).  These commands can accept ASCII, Hex or a combination of the two and the documentation doesn't always clarify.

If you get finished with this and feel you'd like to contribute back a generic ESCP receipt sample to the project, please contact me personally as we'd be happy to offer our trusted version in exchange for a generous contribution.

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

---
You received this message because you are subscribed to the Google Groups "jZebra users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jzebra-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paresh Patel

unread,
Sep 5, 2014, 10:19:19 AM9/5/14
to jzebra...@googlegroups.com
Sure, i will let you know about some programming with jZebra with all details once i complete with my work.

I searched for emulator for EPSON and i found PRTWIN, http://www.araisa.com/ . but could NOT found it working with this code.

Its really always nice talks with you.

Tres Finocchiaro

unread,
Sep 5, 2014, 10:26:33 AM9/5/14
to jZebra users
Cool find.  Yes, I believe that is designed for different printers as they don't specifically mention the ESCP escape commands, which are primarily used for the point of sales rather than dot matrix reporting.

-Tres

Paresh Patel

unread,
Sep 30, 2014, 9:12:57 AM9/30/14
to jzebra...@googlegroups.com
Hi Tres
Hope you are doing well !

I am near to complete receipt print.

Currently i am facing issue with designing receipt. I am successfully bold,center text etc but not know how to manage listing.
See attached image

Is there any sample or command to manage such list like we manage in table with tr and td ? i have that image having commands of 'Sample ESC/P' but could not help me.


l
Receipt_Sample.jpg

Tres Finocchiaro

unread,
Sep 30, 2014, 11:36:45 AM9/30/14
to jZebra users
@Paresh,

From what I understand, most people have special JavaScript functions which create the correct amount of spaces to simulate tabs.

This is not something I've tried before, sorry.  Perhaps other can help.

Jose Gallegos

unread,
Sep 30, 2014, 11:45:11 AM9/30/14
to jzebra...@googlegroups.com
Hello

Yes, I have made some of those implementations in PHP, the way I do it is with spaces like these:

/**
* @param int $x
* @param int $y
* @param string $text
* @return Fortia_JZebra
*/
public function leftText($x, $y, $text, $maxWidth = null)
{
$text = $this->_cleanText($text);
if($maxWidth)
{
$text = substr($text, 0, $maxWidth);
}
$this->_initLine($y);
//ahora reemplazamos la cadena
$this->_lines[$y] = substr(substr_replace($this->_lines[$y], $text ,$x, strlen($text)), 0, $this->_maxWidth);
return $this;
}




-------------------


public function boxText($x, $y, $text, $width)
{
//colocaremos un escape.. por si no hay ancho
if(!$width)
{
$width = 80;
}
//primero dividimos el texto, en saltos de linea
//$lines = explode("\r\n", $text);//trimeamos con retorno de carro y salto de linea
$lines = preg_split("/[\r\n]+/", $text);//trimeamos con retorno de carro y salto de linea
//ahora examinamos cada linea, para que no pase del width determinado
$printedLines = 0;
foreach ($lines as $line)
{
$line = trim($line);
if($line)
{
while(strlen($line) > $width)
{
//si es mayor al ancho, cortamos por espacios
$cut = strrpos(substr($line, 0, $width), ' ');
if($cut === false)//si no hay ningun espacio, cortamos a la mala por el ancho
{
$cut = $width;
}
$cut++;//+1 por el espacio en blanco
$subline = substr($line, 0, $cut);
$this->leftText($x, $y, $subline);
$printedLines++;
$y++;
//y actualizamos la linea
$line = substr($line, $cut);
}
$this->leftText($x, $y, $line);
$printedLines++;
$y++;
}
}
return $printedLines;
}

------------------

My results:

Nro. Serie: FFFF101032                  
Cod.Autorizacion: 0053845045488         
Ticket: 064-00000657           ID: 26498
Fecha: 2014-09-25         Hora: 11:06:26
Nombre: NICOLAS VALENCIA                
DNI: 41258911                           
ID CLIENTE: 3941 USR: 1                 
----------------------------------------
Cantid. Producto                SubTotal
----------------------------------------
   3.00 LLANTA PIRELLI           1111.20
        205/55R16 PHANTOM 91W           
   1.00 LLANTA PIRELLI              0.00
        205/55R16 PHANTOM 91W           
----------------------------------------
                 Subtotal:        941.69
                      IGV:        169.51
                    TOTAL:       1111.20
SON: MIL CIENTO ONCE  CON 20/100 NUEVOS 
SOLES                                   
----------------------------------------

I even have a "table" implementation, but it's much more complicated

Hope this helps...



 
 
<jm />

Reply all
Reply to author
Forward
0 new messages