第一范文网 - 专业文章范例文档资料分享平台

C#调用把BarTender模板

来源:用户分享 时间:2025/5/15 6:03:27 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

?

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模板 的文档
C#调用把BarTender模板.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c18gms1tqyv5dq8n1sig30fluh9boav00um5_5.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top