Bartender条码使用方法C#

来源:互联网 发布:apache 跨域访问配置 编辑:程序博客网 时间:2024/06/11 18:25

去官网下载10.1版本,http://www.bartender.cc/xiazai.html

安装在C盘较好吧C:\ProgramFiles (x86)\Seagull\BarTender Suite

再下载破解补丁软件http://www.cc.cc/soft/201508271679.html

这个破解补丁是希望安装在C盘的吧,哈哈。

破解后红框处不会出现“演示”二字,因为演示版在程序里不能打印


VS2005引用Seagull.BarTender.Print.dll,这个DLL文件在

C:\Program Files (x86)\Seagull\BarTenderSuite\SDK\Assemblies文件夹里


开始做个DEMO打印吧,VS2010代码如下

using System;

usingSystem.Collections.Generic;

usingSystem.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

usingSeagull.BarTender.Print;//这里不能少

using System.Diagnostics;

 

namespace test

{

    public partialclassForm1 :Form

    {

       public Form1()

       {

           InitializeComponent();

       }

 

      

private void button7_Click(object sender, EventArgs e)
        {
            try
            {
                Engine btEngine = new Engine();
                btEngine.Start();
                string lj = AppDomain.CurrentDomain.BaseDirectory + "mb\\test.btw";
                LabelFormatDocument btFormat = btEngine.Documents.Open(lj);
                //LabelFormatDocument btFormat = btEngine.Documents.Open(Path.Combine("D://Barcode//MR//MR//bin//Debug//mb", "test2" + ".btw"));
                


                //对模版相应字段进行赋值
                btFormat.SubStrings["tm"].Value = txt_barcode.Text;
                btFormat.SubStrings["model"].Value = txt_part.Text;


                //指定打印机名
                btFormat.PrintSetup.PrinterName = "IT_Label";
                //改变标签打印数份连载
                btFormat.PrintSetup.NumberOfSerializedLabels = 1;
                //打印份数                  
                btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;


                //Result nResult = format.Print();
                //btFormat.Print();


                Messages messages;
                int waitout = 10000; // 10秒 超时
                Result nResult1 = btFormat.Print("标签打印软件", waitout, out messages);


                btFormat.PrintSetup.Cache.FlushInterval = CacheFlushInterval.PerSession;
                //不保存对打开模板的修改
                //btFormat.Close(SaveOptions.DoNotSaveChanges);
                //结束打印引擎                 
                btEngine.Stop();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception: " + ex.Message);
                return;
            }

        }


BarTender的各种错误和解决方法

1:
Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
在app.config文件里设置
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>


2:
Could not load file or assembly 'Seagull.BarTender.Print, Version=10.1.4.1, Culture=neutral, PublicKeyToken=109ff779a1b4cbc7' or one of its dependencies. An attempt was made to load a program with an incorrect format.
其他信息: 未能加载文件或程序集“Seagull.BarTender.Print, Version=10.1.4.1, Culture=neutral, PublicKeyToken=109ff779a1b4cbc7”或它的某一个依赖项
于是在项目->属性->生成,将目标平台改成x86,编译即能通过。