zoukankan      html  css  js  c++  java
  • 使用Delphi调用条形码控件BarTender打印标签

    1. 要实现的条形码功能
    最近一个项目需要在扫描条码后按固定的格式打印。条形码打印控件客户习惯使用的是BarTender,使用Delphi调用BarTender来完成打印条码标签功能。此功能的重点在于:
    a)         使用BarTender格式打印
    b)        格式中有需要变动的部分
    2.  条形码标签设计
    a)       新建一个空白标签
    b)      在画面上加入一个条形码控件,一个文本控件
    c)       选中条形码控件,双击(或右键,属性),打开属性窗口;点击“高级”,选择“共享/名称”页,在共享名称中输入条形码控件的名字“BarCode1”;点击确定完成修改。这个步骤来定义在Delphi中(或其它语言VB等)访问的对象名。
    d)      同样的步骤,给文本控件设置名称为“Text1”
    e)       保存为“c:/test.btw”
    3.  导入ActiveX组件
    a)         打开Delphi(版本5.0及以上,其它没有测试)
    b)        选择菜单“项目”à“导入类型库”(ProjectàImport Type Library)
    c)         在弹出的窗口中,列出可导入的类型库;找到“BarTender 7.75”,选中
    d)        将要导入的类名称会列在class names中,由于这里的类名称会与系统已存在类名称有重复,将这个全部复制出来,将类型名称前面都加上Bt。如:TFormat修改为TBtFormat.
    e)         类名称修改完成后,点击”安装”(Install)
    f)         系统会安装组件到ActiveX控件页上
    4. 调用BarTender打印
    a)         新建应用程序
    b)        在窗体上拖一个TBtApplication控件(ActiveX页上),命名为btApp1
    c)         在窗体上放一个TButton控件,命名为btn1,双击btn1产生事件
    d)        填写事件代码如下:
    procedure TForm1.btn1Click(Sender: TObject);
    begin
     with btApp1.Formats.Open('c:/test.btw', True, '') do //打开标签文件
     begin
        SetNamedSubStringValue('BarCode1', '1234567890'); //设置值
        SetNamedSubStringValue('Text1', 'Hello BarTender!');
        PrintOut(False, False); //打印
        Close(btDoNotSaveChanges); //关闭不保存
     end;
     btApp1.Quit(btDoNotSaveChanges); //退出
    end;
     

     
    0
    ------


    The Formats.Open method has three arguments. The first argument is required and is a string containing the path of the label format file to open. The second argument is a Boolean: if it is true, the method will close the default blank format called "Format1" that BarTender automatically opens when it starts. It cannot close formats that have any other name. The third argument specifies a printer to use.

    If you have multiple formats opened in BarTender, you can use the Formats collection object to return a reference to any opened format. A format can be identified by specifying either the format name or index identifier. You can also bring focus to an opened label format using the Format.Activate method. The following example assigns the specified label format (Format1.btw) to be the active label format in BarTender.

  • 相关阅读:
    spark之手机基站定位数据的商圈分析
    spark之客户流失预测
    spark之AHP层次分析顾客价值得分
    Web-Attak系列教程第二季0x13讲——信息收集
    Web-Attak系列教程第二季0x12讲——HTTP的请求与响应格式
    Python编程系列教程第14讲——继承
    独孤九剑与黑客编程
    Python编程系列教程第15讲——多态
    Python编程系列教程第16讲——拷贝自身到系统目录
    再谈独孤九剑与黑客编程
  • 原文地址:https://www.cnblogs.com/xionda/p/6066370.html
Copyright © 2011-2022 走看看