Raw Printing

Raw Printing is when you send a string of commands to a printer in its own language, without using printer drivers.

This method is often used for thermal printers that need raw command inputs to do things like:

  • Printing barcodes
  • Printing receipts
  • Printing labels
  • Cutting paper
  • Opening the cash drawer

Raw Printing is faster and more reliable than other methods because it doesn't use drivers. This is especially true for POS systems.

1. How to set up Raw Printing in ERPNext

1.1 Putting the QZ Tray app on the client's computer

Install the QZ Tray app on the computer that is connected to your thermal printer to get started with Raw Printing. The official QZ Tray website has a link where you can get it.

Operating Systems That Are Supported:

  • Windows
  • macOS
  • Linux
Note: If you don't already have Java installed, the QZ Tray installation will ask you to do so.

1.2 Make a print format for raw commands

You need to make a print format in ERPNext using raw commands before you can send raw commands to the printer. Just like HTML print formats, these print formats use the Jinja Templating Language.

How to make a Raw Commands Print Format:

  1. Go to: Home > Settings > Printing > Format for Printing

  2. Press New

  3. Choose the right DocType, like "Sales Invoice."

  4. Check both choices:

    • Custom format

    • Raw Printing

  5. Type the printer-specific raw language commands into the Raw Commands field.

  6. Press Save

raw printing
Note: Keep in mind that the raw command syntax varies by printer model and brand. You need to look at the developer documentation for your printer (for example, ESC/POS commands).

1.3 Turn on Raw Printing in the Print Settings

To turn on Raw Printing for everyone:

  1. Go to: Home > Settings > Printing > Print Settings > Raw Printing

  2. Check the box that says "Enable Raw Printing."

  3. Click on Save.

2. Ways to Use Raw Printing in ERPNext

There are two main ways to start raw printing in ERPNext:

2.1 Clicking Print on the Print View Page

From the print view of the document:

  1. Choose your Raw Print Format. You will see No Preview available because raw commands don't show a preview.

  2. Press the Print button

  3. QZ Tray will show you a connection prompt.

What is the purpose of printer mapping?

  1. It connects the chosen print format to a certain printer

  2. You need to install your printer on the client machine.

  3. Each client's device saves the mapping locally.

  4. You can also manage it later by clicking the Printer Settings button.

This makes sure that the right printer gets the raw command for every print job.

2.2 How to Call Raw Print Functions from a Client Script

You can automate raw printing by calling print functions from a client script, like when you click Submit, Save, or Amend.

These are the main functions:

Important:

  1. You can also use the qz object to access QZ Tray's built-in methods.

  2. You can only initialise the qz object after you call frappe.ui.form.qz_connect.

  3. Use frappe.ui.form.qz_init if you need it sooner.

  1. Print Format Builder

  2. Print Style

4. More to Follow

Discard
Save

On this page

Review Changes ← Back to Content
Message Status Space Raised By Last update on