How to print a report in ZPL format

The new version of FastReport .NET 2018.1 has a new export to the ZPL (Zebra Programming Language) format. This format is designed to be used in conjunction with special label printers. More information about ZPL can be found in the article "Page description language – ZPL".

When developing reports that are supposed to be printed on a label printer, the following points should be considered:

• the page size must match the label size, you can adjust the dimensions in the report designer in the Page Setup in the Report menu;

• the fields specified in the page size setting window are also taken into account - if you need to print close to the edge of the label, you need to set the fields to 0;

• Each generated report page will be sent to the printer as a separate label;

• When drawing up a report, you should adhere to a black and white color scheme.

You can create a file with a set of ZPL commands from the preview window.

If there is no label printer available or for economical purposes, you can test the saved file in the Online ZPL Viewer (http://www.labelary.com/viewer.html) - open the generated file with the extension *. Zpl in any text editor, copy it in the text box on the site and click the Redraw button.

You can make additional export settings in the ZPL and send it directly to the label printer from the program code. Look at the demo program in the \ Demos \ C # \ PrintZPL folder.

This is how its main form looks like:

 

First, you select a report template, then set the export options and select the printer to print. It should be a printer that supports the ZPL command system - in our case it's a Zebra ZD420 printer.

In the program code, you can see how the export settings are controlled in the ZPL format - properties of the object of the ZplExport class:

Property

Description

ZplExport.Density

Density of print depends on the printer model.

Possible Values:

ZplExport.ZplDensity.d6_dpmm_152_dpi,
ZplExport.ZplDensity.d8_dpmm_203_dpi,
ZplExport.ZplDensity.d12_dpmm_300_dpi,
ZplExport.ZplDensity.d24_dpmm_600_dpi.

ZplExport.CodePage

A command in the ZPL language that defines the character encoding. It is sent to the printer each time before printing the label. By default it contains the string "^ CI28", which corresponds to the UTF-8 encoding.

ZplExport.FontScale

Scaling the font size. The default is 1.

ZplExport.PrinterFont

A string indicating the type of font, defaults to "A".

ZplExport.PrintAsBitmap

Print as a bitmap. The default is set to true.

ZplExport.PrinterInit

A string with a set of commands that will be sent once to the printer before the report is printed. Can be used to set orientation, override fonts, or other printer settings.

ZplExport.PrinterFinish

A string with a set of commands that will be sent once to the printer after the report is printed.

ZplExport.PageInit

A string with a set of commands that will be sent to the printer before printing each label.

Sending to print is done by using the FastReport.Export.Text.TextExportPrint.PrintStream method, which passes the stream with ZPL commands to the printer's print queue.

Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.
Trustpilot