Sending a string of commands to a printer directly in its native language is called Raw Printing.
Many thermal printers need these raw commands sent to them in order to perform functions like barcode printing, receipt printing, label printing, etc. Raw Printing bypasses the printer's drivers in most cases, making them very fast and reliable. Raw Printing is also capable of doing some advanced features such as cutting receipt paper, kicking out cash drawers, etc.
1. Setting up Raw Printing in iVendNext
1.1 Installing QZ Tray application on the client computer
Download and install the QZ Tray application on the computer to which your thermal printer is connected. This application can be found at its official site. Currently, Windows, macOS, and Linux are supported by QZ Tray. During the installation you will be prompted to install Java if not already installed, please install Java to complete the installation.
Further instructions on installing the QZ Tray Application can be here.
1.2 Create Raw Commands Print Format
To be able to send raw commands to a printer you need to first create a print format in raw commands. Jinja Templating Language is used in raw commands just like in the HTML custom print format.
To create a new print format for Raw Printing:
Go to print format list:
Home > Settings > Printing > Print Format
Click on New.
Select the relevant DocType.
Check the Custom format and Raw Printing options.
Fill in the Raw Commands field with the required raw commands to be sent to the printer.
Click Save.
Currently, any string-based printer languages can be used in the Raw Commands field in the print format. Writing raw commands requires knowledge of the printer's native language provided by the printer manufacturer. Please refer to the developer manual provided by the printer manufacturer on how to write their native commands.
1.3 Enable Raw Printing in the Print Setting
To enable Raw Printing:
Go to:
Home > Settings > Printing > Print Settings > Raw Printing
Check the Enable Raw Printing option.
Save.

2. Methods to utilize raw printing in iVendNext
There are two ways to send Raw Printing commands to your printer.
2.1 Clicking print on the print view page
To print a raw command print format from the Document print view:
Select appropriate print format. For print format in Raw Commands, "No Preview available" message is shown in place of the print preview.
Click on the print button.
Please allow the connection prompt from the QZ Tray for the actions that you initiated (Keyboard Shortcut: Alt + A).
You may be asked to select the "print format - printer mapping".
This "print format - printer mapping" is used to send the print commands to the appropriate printer.
The printer needs to be installed on your computer to be able to map it to a print format.
This mapping is stored locally on the same computer and will have to be set on each client machine.
You can also edit this by clicking on the Printer Settings button.
2.2 Calling Raw Print functions from a client script
You often need a print command to go out on a certain event, such as submit, save or amend. A developer can add a script to do this in Desk's Client Script. Search Desk for Client Script, make a new one, and choose the form as its DocType. See Client Scripts for how a Client Script is made and saved.
The script can use four helpers for raw printing:
-
Connect to the QZ Tray application. It works whether the connection is already open or not, so the script can call it before every command. It finishes when the connection is ready.
-
Get the list of printers that QZ Tray can see. It finishes with a list of printer names.
-
Show the alert "Print Sent to the printer!". The script calls it after a print command goes out.
-
Show the error message to the user. The script calls it when the QZ Tray connection fails.
The script can also use the functions of the qz-tray.js library through its qz object. Click here for qz-tray.js library documentation. The qz object is ready after the script connects to QZ Tray for the first time.