|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
请参考以下C#代码,实测是可以用的。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using BarTender;
namespace TESTWinForm
{
public class LabelPrintHelper
{
public static void FileToBarCodePrint(string strFilePath, string BarTend)
{
BarTender.Application btApp = new BarTender.Application();
BarTender.Format btFormat;
BarTender.BtPrintResult btPrintRtn;
BarTender.Messages btMsgs = null;
btFormat = btApp.Formats.Open(strFilePath, false, String.Empty);
btPrintRtn = btFormat.Print("", false, -1, out btMsgs);
if (btPrintRtn != BarTender.BtPrintResult.btSuccess)
{
foreach (BarTender.Message msg in btMsgs)
{
throw new Exception(msg.Message);
}
}
btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges);
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
}
public static void FileToBarCodePrint2(string strFilePath, string BarFile)
{
string path = @"C:\Program Files\默认公司名称\Bartender.txt";
File.WriteAllText(path, BarFile, Encoding.UTF8);
FileToBarCodePrint(strFilePath, "");
}
private string GetDefaultPrintName()
{
System.Drawing.Printing.PrintDocument prtdoc = new System.Drawing.Printing.PrintDocument();
return prtdoc.PrinterSettings.PrinterName;
}
}
}
|
|