输出图片格式BARTENDER

try

            {
                BarTender.Application btApp = new BarTender.Application();
                BarTender.Format btFormat;
                string tagTemplatesPath = Path.Combine(Application.StartupPath, "testlabel.btw");
                btFormat = btApp.Formats.Open(tagTemplatesPath, false, "");//D:\testlabel\testlabel.btw


                btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;  //设置同序列打印的份数


                //btFormat.Databases.QueryPrompts.GetQueryPrompt(0);//根据数据库数据打印


                //这个是序列化打印时使用的,当你的标签启动了序列化后,这个属性代表的就是打印的份数,譬如你的序列化初始数据是1,增量为1,NumberSerializedLabels设置为5,那么就会打印出1、2、3、4、5,五个标签出来。
                //btFormat.PrintSetup.NumberSerializedLabels = 2;  //设置需要打印的序列数 




                btFormat.SetNamedSubStringValue("Label_data01", DateTime.Now.ToString("HHmmss")); //向bartender模板传递变量
                btFormat.PrintOut(false, false); //第二个false设置打印时是否跳出打印属性


                //BarTender.Messages msg;
                //int waitout = 10000; // 10秒 超时
                //btFormat.Print("任务名1", true, waitout, out msg);//打印的任务名,是否等待打印完成,等待超时时间,打印过程输出的信息。


                btFormat.Close(BarTender.BtSaveOptions.btSaveChanges); //退出时是否保存标签
                btApp.Quit(BarTender.BtSaveOptions.btSaveChanges);//界面退出时同步退出bartender进程
            }
            catch (Exception ex)
            {
                string path = Path.Combine(Application.StartupPath, "printlog.txt");
                File.AppendAllText(path, "异常:" + ex.Message + "。\r\n" + DateTime.Now + "\r\n");
                MessageBox.Show(ex.Message);

            }

2.bartender导出图片

 BarTender.Format btFormat;
         BarTender.Application btApp;
         btFormat = new BarTender.Format();
         btApp = new BarTender.Application();

string file = HttpContext.Current.Server.MapPath("/templatefile/testlabel.btw");
            btFormat = btApp.Formats.Open(file, false, "");
            btFormat.PrintSetup.NumberSerializedLabels = 1;
            btFormat.SetNamedSubStringValue("Label_data01",DateTime.Now.ToString("mmss"));

            btFormat.SaveAs(file, true);

            btFormat.ExportToFile(HttpContext.Current.Server.MapPath("/templatefile/BarCodeTable.jpg"), "jpg", BarTender.BtColors.btColors24Bit,              BarTender.BtResolution.btResolutionPrinter, BarTender.BtSaveOptions.btSaveChanges);
            Image1.ImageUrl = "~/templatefile/BarCodeTable.jpg";
            btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);
            //打印
            btFormat = btApp.Formats.Open(file, false, "");
            //同一个条码,打印5个
            //btFormat.PrintSetup.IdenticalCopiesOfLabel = 5;   
            //条码递增+1
            //btFormat.PrintSetup.NumberSerializedLabels = 4;
            btFormat.PrintOut(false, false);
            btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);

猜你喜欢

转载自www.cnblogs.com/qiu18359243869/p/10238550.html