3.4.1 Print Label (C#)

Sample source code for print label
ShipmentsCredentials cred = new ShipmentsCredentials(); cred.UserName = "username"; cred.Password = "password"; cred.CultureType = CultureType.English; ShipmentsConfiguration config = new ShipmentsConfiguration(); config.LabelFormat = LabelFormat.Pdf; config.LabelSize.Inch_6x4; LabelParameter par = new LabelParameter(); par.ShipmentsCredentials = cred; par.ShipmentsConfiguration = config; par.TrackReport = TrackReport.Label; par.LabelType = LabelType.BothLabel; par.HawbNo = new string[2]; par.HawbNo[0] = "344010500000151"; par.HawbNo[1] = "344010500000125"; ShipmentsClient client = new ShipmentsClient(); ReportResponse res = client.GenerateReport(par); if (res.ErrorCode == "0") { byte[] bytespdf = Convert.FromBase64String(res.LabelImageString); string filename = "abc.pdf"; FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write); fs.Write(bytespdf, 0, bytespdf.Length); fs.Close(); } else { string error = res.ErrorMessage; }
Copyright © 2018 Unixus Solutions Sdn. Bhd. All rights reserved.