小编man*_*mar的帖子

ZPL将参数传递给标签会打印错误的数据

我们使用Zebra Designer Pro来创建模板.我们在模板上放置了各种标签,我们通过运行时的代码动态传递值.

我们这样做是通过在代码中创建ZPL并附加我们想要在ZPL中打印的各种参数值.创建标签的方法如下:

        private string GetPrinterInstruction(string templateName, IList<string> variables, int numberOfCopies)
        {
            StringBuilder printerInstruction = new StringBuilder();

            //start the label format and sets the field origin
            printerInstruction.AppendLine("^XA");

            //Template
            printerInstruction.AppendLine("^XF");
            printerInstruction.AppendLine(templateName);
            //Field Separator
            printerInstruction.AppendLine("^FS");


            // for each Variable
            for (var i = 1; i <= variables.Count; i++)
            {
                //Assign field number FN1..FN2
                printerInstruction.AppendLine("^FN");
                printerInstruction.AppendLine(i.ToString());

                //Indicate start of field data
                printerInstruction.AppendLine("^FD");

                //Field data
                printerInstruction.AppendLine(variables[i - 1]);

                //Field Separator
                printerInstruction.AppendLine("^FS");
            }

            //Printing Quantities of Labels,
            printerInstruction.AppendLine("^PQ" + numberOfCopies);

            //indicates the end of …
Run Code Online (Sandbox Code Playgroud)

c# zpl

2
推荐指数
1
解决办法
4880
查看次数

标签 统计

c# ×1

zpl ×1