In new versions of their API, they do not have LabelSpecification
object so this solution might help you. These settings would help you for a thermal printer:
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";
From above code, you can see because they are accepting an array for image settings, this means it should return multiple images with different specifications.
And this is how I am converting the returned label image and saving it onto the server:
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();
}