BarTender官方的SDK只支持.NET Framework,無法在.NET Core環境下使用,但其實.NET Core環境下還是有辦法使用BarTender的,那就是直接呼叫底層的COM組件,
在專案中添加參考COM:Interop.BarTender
案例代碼:
1 public void Print(List<PrinterInput> inputs) 2 { 3 BarTender.Application BtApp = new BarTender.Application(); 4 PrintDocument printDoc = new PrintDocument();
7 BarTender.Format btFormat = BtApp.Formats.Open(Path.Combine(AppContext.BaseDirectory, "Template", "Label.btw")); 8 btFormat.PrintSetup.Printer = printDoc.PrinterSettings.PrinterName;
19 foreach (var input in inputs) 20 { 21 btFormat.SetNamedSubStringValue("PartNum", input.PartNum); 22 btFormat.SetNamedSubStringValue("PartDescription", input.PartDescription); 23 btFormat.SetNamedSubStringValue("LotNum", input.LotNum); 24 btFormat.SetNamedSubStringValue("Qty", input.Qty); 25 btFormat.PrintOut(); 26 }
28 btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges); 29 BtApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
31 }
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/66455.html
標籤:.NET Core
上一篇:.NetCore之介面快取
下一篇:C#實作圖層疊加
