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.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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?