我已经为usps服务器上正常工作的打印标签做了代码。我只需要打印pdf。我怎么能这样做?
private void BindDetail()
{
//to test the upsp used below code
USPSManager m = new USPSManager("USERID", false);
Package p = new Package();
p.FromAddress.Contact = "John Smith";
p.FromAddress.Address2 = "475 L'Enfant Plaza, SW";
p.FromAddress.City = "Washington";
p.FromAddress.State = "DC";
p.FromAddress.Zip = "20260";
p.FromAddress.ZipPlus4 = "2060";
p.ToAddress.Contact = "Tom Customer";
p.ToAddress.Address1 = "STE 201";
p.ToAddress.Address2 = "6060 PRIMACY PKWY";
p.ToAddress.City = "Memphis";
p.ToAddress.State = "TN";
p.ToAddress.Zip = "20219";
p.ToAddress.ZipPlus4 = "2022";
p.WeightInOunces = 2;
p.ServiceType = ServiceType.Priority;
p.SeparateReceiptPage = false;
p.LabelImageType = LabelImageType.PDF;
p.PackageSize = PackageSize.Regular;
p.PackageType = PackageType.Flat_Rate_Box;
// p.ShippingLabel=
p = m.GetDeliveryConfirmationLabel(p);
}
答案 0 :(得分:0)
正如您所提到的,您已经完成了代码并且您正在获取响应表单服务器;然后,为了打印您需要将GetDeliveryConfirmationLabel转换为图像的标签,您将拥有一个名为delivery_confirm.tif的文件,您可以将其打印到图像中。您可以使用base64String中的以下内容来映像
public Image Base64ToImage(string base64String)
{
// Convert Base64 String to byte[]
byte[] imageBytes = Convert.FromBase64String(base64String);
MemoryStream ms = new MemoryStream(imageBytes, 0,imageBytes.Length);
// Convert byte[] to Image
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
return image;
}