-
Notifications
You must be signed in to change notification settings - Fork 101
2.0 Getting Started
###Compatibility
Product | Version | Supported |
---|---|---|
QZ Tray | 2.0 | ✅ Per Roadmap |
QZ Tray | 1.9 | 🚫 Per Roadmap |
QZ Print | 1.9 | 🚫 Per Roadmap |
This is a tutorial for web developers to add a plugin to your web page capable of sending raw commands to your printer. This is common for Barcodes, Thermal Printing, Point-Of-Sales (POS), and other commercial/industry purposes.
This is possible by using JavaScript to talk to the QZ Tray 2.0 software using techniques supported provided by all major web browsers and all major Desktop operating systems.
##Preliminary Steps
This tutorial assumes you have already successfully completed the following tasks:
-
QZ Tray 2.0 is installed and is working properly in the web browser
-
Your printer is connected and configured properly.
- Note: For raw printing to function properly, special steps may be needed:
##The Code
These code examples are also available in sample.html
file provided with QZ Tray installation available via QZ Tray, Advanced, Open File Location, demo
-
First, make sure
qz-tray.js
is included in your web page as well as an ECMAScript 6 Promise library (we include RSVP but support others). -
Call
qz.websocket.connect()
to bind to a local websocket instance of QZ Tray.qz.websocket.connect().then(function() { alert("QZ Tray connected"); });
-
This code example uses
qz.printer.find(..)
to find a printer named "zebra" and set it as the currently selected printer.qz.printers.find("zebra").then(function(printer) { alert("Found " + printer); });
- See also
sample.html
sectionfindPrinter()
- See also
###Raw Printing / Pixel Printing
Depending on what type of printer you have, various functions can be used.
- Raw Printing
The Raw Printing Guide goes over how to do the following with a Raw Printer:
- Sending Raw Commands (Java / php)
- Base64 Printing
- Epson/Citizen ESC/P Printing
- Advanced Print Spooling
- Print Special Characters
- File Printing
- XML Printing
- Pixel Printing
The Pixel Printing Guide goes over how to do the following with a standard desktop printer:
- Print to a File
- HTML Printing
- PDF Printing
- Printing Images
###Serial Communication
- If you would like to send and receive commands through a serial connection, please read the Serial Communication tutorial.