FastReport .NET 2018.1的新版本具有对ZPL(斑马编程语言)格式的新导出。该格式旨在与特殊标签打印机一起使用。

在开发应该在标签打印机上打印的报告时,应考虑以下几点:

•页面大小必须与标签大小匹配,您可以在“报告”菜单的“页面设置”中的报告设计器中调整尺寸;

•还考虑了在页面大小设置窗口中指定的字段-如果需要在标签边缘附近打印,则需要将这些字段设置为0;

•每个生成的报告页面将作为单独的标签发送到打印机;

•编写报告时,应遵循黑白配色方案。

您可以从预览窗口使用一组ZPL命令创建文件。

 

密度参数负责打印密度,即每毫米点数。选择的浓度取决于将来要在其上打印标签的打印机。
“打印为位图”复选框表示报告图像的每像素副本将发送到打印机。换句话说,将生成报告的黑白图像,并以ZPL格式将其另存为图片。如果禁用此复选框,则报表对象将另存为ZPL命令序列。文本值以UTF-8编码存储,条形码(在ZPL中具有相应类似物的条形码)作为单独的命令进行传输。

应该记住的是,当将报告打印为图片时,条形码可能无法读取即使它们看起来与我们在报告中看到的相同。出现这种条形码行为的原因是由于条形码对象缩放导致的线宽比例不正确。为避免读取条形码时出错,应禁用“打印为位图”模式,但是在这种情况下,条形码的外观可能与我们在预览窗口中看到的外观不匹配。
字体缩放参数负责缩放字体大小。


如果没有可用的标签打印机或出于经济目的,您可以在Online ZPL Viewer(http://www.labelary.com/viewer.html)中测试保存的文件-打开扩展名为*的生成的文件。在任何文本编辑器中使用Zpl,将其复制到站点上的文本框中,然后单击“重绘”按钮。

您可以在ZPL中进行其他导出设置,然后将其从程序代码直接发送到标签打印机。查看\ Demos \ C#\ PrintZPL文件夹中的演示程序。

 

 

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.

posted on 2021-05-04 09:51  Gu  阅读(212)  评论(0编辑  收藏  举报