public Task<HttpResponseMessage> PrintBlankTag(int stationId, BlankTag tagInfo) { var tcs = new TaskCompletionSource<HttpResponseMessage>(); try { DispositionDatabase dbDisposition = new DispositionDatabase(); var printer = dbDisposition.GetPrinter(stationId); string printerName = printer.Location.Trim(); //string printerName = "\\\\s1vprint01\\HP LaserJet 400 M401 - IT Office"; //string printerName = "\\\\itlaptopwong\\HP LaserJet 400 M401 - IT Office"; MultiPrintDocument multiDoc; List<PrintDocument> printList = new List<PrintDocument>(); PrintDocument print = new PrintDocument(); print.DefaultPageSettings.Landscape = true; print.DefaultPageSettings.PaperSize = new PaperSize("Label", 400, 600); print.PrintPage += (sender, args) => CreateBlankLabel(tagInfo, args.Graphics); print.EndPrint += (sender, args) => { tcs.TrySetResult(new HttpResponseMessage(HttpStatusCode.OK)); }; printList.Add(print); PrintDocument[] printDocList = new PrintDocument[printList.Count]; for (int i = 0; i < printList.Count; i++) printDocList[i] = printList[i]; multiDoc = new MultiPrintDocument(printDocList); multiDoc.PrinterSettings.PrinterName = printerName; multiDoc.DefaultPageSettings.Landscape = true; multiDoc.DefaultPageSettings.PaperSize = new PaperSize("Label", 400, 600); multiDoc.DocumentName = "Disposition Tag"; if (multiDoc.PrinterSettings.IsValid) multiDoc.Print(); else { tcs.TrySetResult(new HttpResponseMessage(HttpStatusCode.RequestTimeout)); } } catch (Exception ex) { tcs.TrySetResult(new HttpResponseMessage(HttpStatusCode.RequestTimeout)); } return tcs.Task; }