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

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值