环境: 采用BarTender btw模板
实现方式:转化成图片,通过图片控件,显示出图片效果即可
核心代码:
private BarTender.Application btapp;
private BarTender.Format printFormat;
private void test()
{
try
{
btapp = new BarTender.Application();
printFormat = btapp.Formats.Open(@"E:\\Test.btw", false, "");
printFormat.PrintSetup.IdenticalCopiesOfLabel = 1; //设置同序列打印的份数
printFormat.PrintSetup.NumberSerializedLabels = 1; //设置需要打印的序列数
printFormat.SetNamedSubStringValue("4位年月日", "2019"); //向bartender模板传递变量
BarTender.Messages msgs;
string url = AppDomain.CurrentDomain.BaseDirectory;
string name = "Label_2_Preview.jpg";// "Label_%PageNumber%_Preview.jpg";
printFormat. ExportToFile(url+name, "jpg", BarTender.BtColors.btColors256, BtResolution.btResolutionPrinter, BtSaveOptions.btSaveChanges);
pictureBox1.Image = Image.FromFile(url+name);
printFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges);
} catch (Exception ex)
{ }
}
最总效果: