【问题标题】:How to convert a ZPL code into a image using c#如何使用 c# 将 ZPL 代码转换为图像
【发布时间】:2020-03-03 16:35:56
【问题描述】:

我从系统中集成的服务收到 Zpl 代码的响应,我想要的只是将 Zpl 代码转换为图像

我试过http://labelary.com/,但它对免费的公共服务有限制,因为它的无限服务太贵了。

我也尝试阅读 zpl 代码手册来创建解析器,但失败了 https://www.zebra.com/content/dam/zebra/manuals/printers/common/programming/zpl-zbi2-pm-en.pdf

【问题讨论】:

  • 您需要解析大约 1500 页的规范。或获取某人的图书馆.. 在你问之前,我们不在这里要求图书馆
  • @TheGeneral 我发现只有一个库是免费的,可以将 zpl 转换为图像,但正如我上面提到的,它有局限性。我希望如果有人已经创建了解析器或者可以在解析方面指导我一点
  • 您能告诉我们您在哪里或为什么没有编写自己的解析器吗?

标签: c# .net image converters zpl-ii


【解决方案1】:

您可以尝试使用 Api 请求,即

byte[] zpl = Encoding.UTF8.GetBytes("^xa^cfa,50^fo100,100^fdHello World^fs^xz");

// adjust print density (8dpmm), label width (4 inches), label height (6 inches), and label index (0) as necessary
var request = (HttpWebRequest) WebRequest.Create("http://api.labelary.com/v1/printers/8dpmm/labels/4x6/0/");
request.Method = "POST";
request.Accept = "application/png"; // omit this line to get PNG images back
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = zpl.Length;

var requestStream = request.GetRequestStream();
requestStream.Write(zpl, 0, zpl.Length);
requestStream.Close();

try {
    var response = (HttpWebResponse) request.GetResponse();
    var responseStream = response.GetResponseStream();
    var fileStream = File.Create("label.pdf"); // change file name for PNG images
    responseStream.CopyTo(fileStream);
    responseStream.Close();
    fileStream.Close();
} catch (WebException e) {
    Console.WriteLine("Error: {0}", e.Status);
}

参考Link

【讨论】:

    【解决方案2】:

    【讨论】:

      【解决方案3】:

      将 ZPL 代码转换为与标签完全相同的 PNG 的唯一方法是使用 Zebra 打印机进行渲染;o)。

      Industrial Zebra 有一个嵌入式网站,允许您发布 ZPL 代码并获得 PNG 作为回报。这是zpldesigner 使用的。

      Labelary 和其他软件只能“模拟”ZPL 代码。

      【讨论】:

        猜你喜欢
        • 2018-09-22
        • 1970-01-01
        • 2017-12-01
        • 2014-03-04
        • 1970-01-01
        • 1970-01-01
        • 2019-12-16
        • 2012-05-07
        • 1970-01-01
        相关资源
        最近更新 更多