.NET Core:使用BarTender


  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 }

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM