【问题标题】:UPS ZPL Lable size issue I need small size label for my ZP450 printerUPS ZPL 标签尺寸问题 我的 ZP450 打印机需要小尺寸标签
【发布时间】:2014-04-16 21:55:15
【问题描述】:

我想以以下尺寸显示 UPS 标签尺寸:宽度 = 4 英寸,高度 = 8 英寸

但是当我在浏览器上显示时,UPS API 会以 base64 格式返回 GraphicImage

它在我的浏览器上显示非常大尺寸的图像,例如宽度:1400px 和高度:800px;

当我在我的 ZP450 打印机上打印此图像时,它在页面上打印的图像非常小,即使页面上不可读。

非常感谢任何帮助,我如何在浏览器上显示小级别图像

或使用base64代码直接发送打印但我想在页面上打印时打印大尺寸的图像,如UPS.COM打印。

【问题讨论】:

  • 你找到解决方法了吗?

标签: printing size label ups


【解决方案1】:

在将使用 ZPL 格式的 UPS GraphicImage 标签发送到 Zebra 打印机之前,您需要将其从 base64 字符串转换为 ascii 字符串。查看How do I Encode and Decode a base64 string的答案

//...UPS Shipment Request construction...
shipmentRequest.LabelSpecification.LabelImageFormat.Code = "ZPL";
shipmentRequest.LabelSpecification.LabelStockSize.Height = "8";
shipmentRequest.LabelSpecification.LabelStockSize.Width = "4";
//...
// Submit the Shipment Request to the UPS Ship Service
ShipmentResponse shipmentResponse = shipService.ProcessShipment(shipmentRequest);
//...Process the Shipment Response...

// The Label is encoded as Base64 Text.  Decode this to standard ASCII Text
string labelData = Base64Decode(shipmentResponse.ShipmentResults.PackageResults[0].ShippingLabel.GraphicImage);

// Write the label data to a file so it can be printed/reprinted as needed
System.IO.File.WriteAllText(@"C:\temp\UPSlabel.zpl", labelData);

应使用通用文本打印机驱动程序将 ZPL 标签打印为 RAW。只要关闭自动换行、页边距、页眉/页脚/页码设置,您就可以使用记事本编辑和打印标签。 Notepad++ 有效。

我认为这对于 UPS EPL 格式的标签也是如此。

【讨论】:

    【解决方案2】:

    在他们的 API 的新版本中,他们没有 LabelSpecification 对象,所以这个解决方案可能会对您有所帮助。这些设置将帮助您使用热敏打印机:

    shipment.Documents = new DocumentsType();
    shipment.Documents.Image = new ImageType[1];
    shipment.Documents.Image[0] = new ImageType();
    shipment.Documents.Image[0].Type = new ShipCodeDescriptionType();
    shipment.Documents.Image[0].Type.Code = "30";
    shipment.Documents.Image[0].PrintFormat = new ShipCodeDescriptionType();
    shipment.Documents.Image[0].PrintFormat.Code = "02"; // thermal
    shipment.Documents.Image[0].Format = new ShipCodeDescriptionType();
    shipment.Documents.Image[0].Format.Code = "01"; // pdf
    shipment.Documents.Image[0].LabelsPerPage = "1";
    shipment.Documents.Image[0].PrintSize = new PrintSizeType();
    shipment.Documents.Image[0].PrintSize.Length = "4";
    shipment.Documents.Image[0].PrintSize.Width = "6";
    

    从上面的代码可以看出,因为他们接受了一个数组来设置图片,这意味着它应该返回多个不同规格的图片。

    这就是我转换返回的标签图像并将其保存到服务器上的方式:

    if (!string.IsNullOrEmpty(base64) && !string.IsNullOrEmpty(extension))
    {
        byte[] bytes = Convert.FromBase64String(base64);
    
        var path = "~/ShippingLabels/UPS";
    
        if (!Directory.Exists(Server.MapPath(path)))
        {
            Directory.CreateDirectory(Server.MapPath(path));
        }
    
        var filePath = string.Format("{0}/{1}_{2}_{3}.{4}", path, freightShipResponse.ShipmentResults.BOLID, freightShipResponse.ShipmentResults.ShipmentNumber, DateTime.Now.ToString("yyyyMMddmmhhssfff"), extension);
    
        System.IO.FileStream stream = new FileStream(Server.MapPath(filePath), FileMode.CreateNew);
        System.IO.BinaryWriter writer = new BinaryWriter(stream);
        writer.Write(bytes, 0, bytes.Length);
        writer.Close();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-15
      • 1970-01-01
      • 1970-01-01
      • 2012-02-29
      相关资源
      最近更新 更多