云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C#调用把BarTender模板

C#调用把BarTender模板

  • 62 次阅读
  • 3 次下载
  • 2025/7/13 16:57:27

?

Setting the LabelFormatDocument object's PrinterName property

The following code demonstrates opening a label format using the default printer, and opening a label format using a specific printer. In C#:

// Initialize and start a new engine using (EnginebtEngine = newEngine()) {

btEngine.Start();

// Open a label format specifying the default printer LabelFormatDocumentbtFormat =

btEngine.Documents.Open(@\); // Print the label

Resultresult = btFormat.Print(\);

// Open a label format specifying a different printer btFormat = btEngine.Documents.Open(@\, \); // Print the label

result = btFormat.Print(); } In VB:

' Initialize and start a new engine UsingbtEngineAs NewEngine() btEngine.Start()

' Open a label format specifying the default printer DimbtFormatAsLabelFormatDocument =

btEngine.Documents.Open(\) ' Print the label

Dim result As Result = btFormat.Print(\) ' Open a label format specifying a different printer btFormat = btEngine.Documents.Open(\, \) ' Print the label

result = btFormat.Print() End Using

In the above example, a new Engine instance is created and started. The label file MyLabel1.btw is opened and will print using the printer the label format was saved with. The label file MyLabel2.btw will print to the specified printer (OurPrinter_HX3000).

Alternately, the printer name may be changed once the label format is already open. This is accomplished by changing the

LabelFormatDocument'sPrintSetup.PrinterName property.

The following code demonstrates how to change the printer the label format will use to print. In C#:

// Initialize and start a new engine using (EnginebtEngine = newEngine()) {

btEngine.Start();

// Open a label format specifying the default printer LabelFormatDocumentbtFormat =

btEngine.Documents.Open(@\); // Change the name of the printer

btFormat.PrintSetup.PrinterName = @\; // Print the label

Resultresult = btFormat.Print(); }

In VB:

' Initialize and start a new engine UsingbtEngineAs NewEngine() btEngine.Start()

' Open a label format specifying the default printer DimbtFormatAsLabelFormatDocument =

btEngine.Documents.Open(\) ' Change the name of the printer

btFormat.PrintSetup.PrinterName = \ ' Print the label

Dim result As Result = btFormat.Print() End Using

In the above example, a new Engine instance is started and a label format is opened in that Engine instance. The name of the printer is changed before the label prints.

Printing and Print Job Events

The progress of a print job can be monitored by utilizing print job events. The LabelFormatDocument class contains delegates defining different events that can occur during printing. By creating and hooking up event handlers to these delegates, the progress of a print job can be tracked. For more information, refer to Working with Print Job Status Events.

Changing Text and Barcode Data on the Label Format

Label formats may contain named substrings, denoting fields on a label that may be changed. Typically, each substring represents a complete text object, barcode, or RFID tag on a label, although some objects may have more that one substring. By changing the values of these substrings, you

can change the information printed on a label. For more information on how to define substrings on a label, see BarTender's application help.

Reading Named Substrings

Each LabelFormatDocument object contains a Substrings collection. This collection stores a list of all named substrings that are part of a label. The following code demonstrates how to read named substrings. In C#:

EnginebtEngine = newEngine();

LabelFormatDocumentbtFormat =

btEngine.Documents.Open(@\);

stringAddressSubstring = btFormat.SubStrings[\].Value; In VB:

DimbtEngineAs NewEngine()

DimbtFormatAsLabelFormatDocument =

btEngine.Documents.Open(\)

DimAddressSubstringAs String = btFormat.SubStrings(\).Value The above code reads substrings that are explicitly part of the MyLabel label format. These named substrings are specific to MyLabel and might not exist in other label formats. The BarTender Print SDK throws an exception if an attempt is made to access a nonexistent substring.

Modifying Named Substrings

Named substrings not only can be read, but they can be modified

programmatically. The following code demonstrates how to modify named substrings. In C#:

EnginebtEngine = newEngine();

LabelFormatDocumentbtFormat =

btEngine.Documents.Open(@\);

btFormat.SubStrings[\].Value = \Mockingbird Lane, Anywhere, USA\;

btFormat.SubStrings[\].Value = \; btFormat.SubStrings[\].Value = \; In VB:

DimbtEngineAs NewEngine()

DimbtFormatAsLabelFormatDocument =

btEngine.Documents.Open(\)

btFormat.SubStrings(\).Value = \Mockingbird Lane, Anywhere, USA\

btFormat.SubStrings(\).Value = \ btFormat.SubStrings(\).Value = \

The above code modifies substrings that are explicitly part of the MyLabel label format. These named substrings are speci

搜索更多关于: C#调用把BarTender模板 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

? Setting the LabelFormatDocument object's PrinterName property The following code demonstrates opening a label format using the default printer, and opening a label format using a specific printer. In C#: // Initialize and start a new engine using (EnginebtEngine = newEngine()) { btEngine.Start(); // Open a label format specifying the default printer Label

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com