• c# Bartender打印开发详解


    c# Bartender打印开发详解

    Ericw_wang

    于 2020-06-26 20:56:25 发布

    2482
     收藏 5
    分类专栏: Bartender 文章标签: c#
    版权

    Bartender
    专栏收录该内容
    2 篇文章0 订阅
    订阅专栏
    Bartender 打印开发遇到的坑
    打印的写法,目前知道两种实现
    1.引用 插入Bartender 自带dll,写法如下:

    (一般在安装SDK里,可以找到dll)

    using (Engine btEngine = new Engine())
    {
    btEngine.Start();
    //Lable 路径
    LabelFormatDocument btFormat = btEngine.Documents.Open(@“C:\Users\Administrator\Desktop\Bartender_\Labels\Outer.btw”);
    //如何传参 命名具名数据源 赋予对应的 key<>value
    btFormat.SubStrings[“ProductName”].Value = “test1”;
    //传入打印机名称
    btFormat.PrintSetup.PrinterName = “ZDesigner ZT410-300dpi ZPL”;
    //打印张数
    btFormat.PrintSetup.IdenticalCopiesOfLabel = 1;
    btFormat.Print(“UID Printing Job”, 1);
    btFormat.Close(SaveOptions.DoNotSaveChanges);
    btEngine.Stop();
    }
    2.用 COM Bartender,写法如下:

    (这个需要安装Bartender软件,自动寻找)
    // Declare a BarTender application variable
    BarTender.Application btApp;
    BarTender.Format bFormat;
    //Label路径位置
    string strPath = @"";
    // Create a new instance of BarTender
    btApp = new BarTender.Application();
    //打开label
    bFormat = btApp.Formats.Open(strPath,false, “”);
    //传入打印机名称
    bFormat.Printer = “ZDesigner ZT410-300dpi ZPL”;
    // 将对应变量赋值
    bFormat.SetNamedSubStringValue(“ProductName”, “66666666666999”);
    //打印张数
    bFormat.IdenticalCopiesOfLabel = 1;
    bFormat.PrintOut(false, false);
    bFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges); //退出时是否保存标签
    btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);

    ####### 在执行第二种方法时遇到点问题,我的业务场景是:我需要远程去调服务器上的Bartender打印,然后报错权限,错误如下:
    Retrieving the COM class factory for component with CLSID {B9425246-4131-11D2-BE48-004005A04EDF} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).
    (百度了半天,才知道好像是权限问题)
    解决如下—
    <参考:https://blog.csdn.net/lllljz/article/details/44917545 (小生在这里谢过这位大神)>
    ————————————————
    版权声明:本文为CSDN博主「Ericw_wang」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/Ericw_wang/article/details/106974272

  • 相关阅读:
    #DAYU200#OpenHarmony 视频播放器
    Linux安装Tomcat最新版
    java面向对象(八)
    服务器崩溃,主要都有哪些原因又怎么解决服务器崩溃。
    美创科技与南京大数据安全技术有限公司达成战略合作
    C语言中的文件操作指南
    RabbitMQ(五) | MQ集群搭建、部署、仲裁队列、集群扩容
    QT+OSG/osgEarth编译之二十二:librttopo+Qt编译(一套代码、一套框架,跨平台编译,版本:librttopo-1.1.0)
    操作系统的运行机制
    使用Python访问Zookeeper获取数据
  • 原文地址:https://blog.csdn.net/u014090257/article/details/125544986