Wiki - 1.9 Raw Printing



The following code can be used for raw printing only. If you are unsure what raw printing is, please refer to What is Raw Printing?

Raw Commands

  1. JavaScript

    1. Insert (or modify) this JavaScript code to send commands to the printer. This button has already been provided in sample.html
    function print() {
      qz.append("A37,503,0,1,2,3,N,QZ-PRINT TEST PRINT\n");

    See also sample.html section print().

    Note: The raw commands provided in the sample may not work with your printer. Please reference your printer's programming guide for more information.

    1. Add HTML code for a Print button. This button has already been provided in sample.html.
    <input type="button" onclick="print()" value="Print"></input>
    1. Test print.html
      • Load page in web browser and click "Find Printer" button.
      • Click "Print" button.
  2. php

    1. If you would rather use php, replace print() function with this code:
    Using echo
    <?php ?>
      function print() {
         qz.append(<?php echo $commands; ?>);
    Using a dedicated php file
    <?php ?>
      function print() {
      function qzDoneAppending() {

ZPL printing

ZPL sample commands

Base64 printing

With this function, you can send base64 encoded characters/raw commands to qz using "append64". This will automatically convert provided base64 encoded text into text/ascii/bytes, etc.

   function print() {

ESC/P Printing

Epson, Citizen, Star, Bixolon

  1. Optional CHR() function for easier reading.

    function chr(i) {
      return String.fromCharCode(i);
  2. Open cash drawer (usually connected to printer via cable).

    function openCashDrawer() {
      qz.append(chr(27) + "\x70" + "\x30" + chr(25) + chr(25) + "\r");
  3. Cut paper.

    function cutPaper() {
      qz.append(chr(27) + chr(105));       // cut paper
  4. Basic font styling.

    function boldAndCenter() {
      qz.append(chr(27) + chr(69) + "\r");  // bold on
      qz.append(chr(27) + "\x61" + "\x31"); // center justify

Advanced Print Spooling

The ability to control spooling to the printer in batches (e.g. 5, 10, etc). This has advantages due to buffer limitation on certain printer models where submitting 100+ labels randomly stop in the middle of printing. In addition, some programmers have had success with using it for easier reprints.

Special Characters

If special ASCII, CHR, hex or escape characters need to be printed, use the char code, or the \x notation. Note, the NULcharacter (i.e. \x00) is not supported in JavaScript, so appendHex(...) is needed.

   function print() {
     // Appends CHR(27) + CHR(29) using `"fromCharCode"` function
     qz.append(String.fromCharCode(27) + String.fromCharCode(29));

     // Appends hexadecimal data

     // Send characters/raw commands to printer

   // Force special DOS/Win characters on UNIX/Linux
   qz.setEncoding("cp866");       // or

   // Force UTF8 characters on Windows


   // Force MS/DOS Western Europe  (i.e. "Maçã")

   // Submitted via Simon on mailing list
   // Print GBP '£' sign using ESC/P
   // First change code page to UK
   // Then just use '#' where you want your E

File Printing

This feature allows a raw file to be spooled directly to the printer.

XML Printing

The ability to read the contents of an XML file containing Base64 encoded commands and send these commands to the printer. The function requires two parameters, the URL of the XML file and the tagname containing the Base64 encoded text.

Image Printing

Filesystem Printing

Print to local filesystem


Win32 Device Namespace

Some hardware devices -- such as the Bematech Pole Display (previously known as Logic Controls) -- can be installed as a device namespace using the USB driver, e.g. \\.\LCLD9\. This allows Java to bypass the HID interface and send data directly to the device.

Note: If Java displays The handle is invalid, put something after the last backslash, such as dummy

   qz.append("\r\nPlease visit\r\n");
Edit this page