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

C#调用把BarTender模板

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

?

Print(string printJobName, int waitForCompletionTimeout, out Messages messages)

Using the Print Method

Several Print overloads exist; the simplest takes no parameters. The following code shows how to open and print a label format. In C#:

LabelFormatDocumentbtFormat =

btEngine.Documents.Open(@\); Resultresult = btFormat.Print(); In VB:

DimbtFormatAsLabelFormatDocument =

btEngine.Documents.Open(\) Dim result As Result = btFormat.Print()

When this method is called, a Result enumeration is immediately returned. A value of Success indicates that the print job successfully spooled to the printer; a value of Failure indicates otherwise.

The Print method specifies the name of the print job, a flag indicating whether to wait for the print job to complete or not, and a collection of messages. The following code shows how to print a format that is open in the BarTender print engine. In C#:

Messagesmessages = null;

LabelFormatDocumentbtFormat =

btEngine.Documents.Open(@\);

Resultresult = btFormat.Print(\, out messages); In VB:

Dim messages As Messages = Nothing DimbtFormatAsLabelFormatDocument =

btEngine.Documents.Open(\)

Dim result As Result = btFormat.Print(\, messages)

In the above example, the application will immediately resume after the Print method call. In instances where many print jobs are being spooled, an errant print job might delay further printing. In this case it is appropriate to specify a timeout length before the program resumes. If the second parameter is passed as true, then the third parameter indicates the timeout length.

Since the second parameter is passed as false, the timeout parameter should always be set to zero. If the print job is successfully spooled, the method will immediately return with a Success Result value. The Result variable stores the results of the print job, indicating whether the print job has succeeded or failed. Result can indicate the print job has succeeded, timed out, or failed for a variety of reasons. If the result indicates the print job was not successful, the messages collection contains messages indicating any errors BarTender encountered.

The Messages Collection

While printing, one or more messages may be generated indicating print success or error. These messages can be viewed by enumerating the Messages collection returned as a parameter from the Print method. Each Message object in the collection contains a Text property giving a description of the message. The message severity and type can be examined by using the Severity and Type properties, respectively.

Printing Multiple Formats

The Engine class contains a collection of LabelFormatDocument objects that are opened within the BarTender print engine. By looping through this collection, it is possible to print many format files at once. The following code demonstrates a method for printing multiple formats. In C#: int i = 0;

foreach (LabelFormatDocument format inbtEngine.Documents) {

i++;

format.Print(\ + i); } In VB:

Dim i As Integer = 0

For Each format AsLabelFormatDocumentInbtEngine.Documents i += 1

format.Print(\& i) Next format

Every format that is opened in BarTender will be printed and given a print job name corresponding to the order in which it was printed.

Changing the Number of Copies to Print

Printing identical copies of a label or printing serialized copies of a label is common when printing barcode labels. To change the number of identical label copies to print, change the value of Format's

PrintSetup.IdenticalCopiesOfLabel property. To change the number of serialized label copies to print, change the value of Format's PrintSetup.NumberOfSerializedLabels property.

The following code shows how to use IdenticalCopiesOfLabel and NumberOfSerializedLabels. In C#:

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

btEngine.Start(); // Open a label format.

LabelFormatDocumentbtFormat =

btEngine.Documents.Open(@\);

// Change the number of identical labels and serialized labels to print btFormat.PrintSetup.NumberOfSerializedLabels = 4; btFormat.PrintSetup.IdenticalCopiesOfLabel = 10; // Print the label

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

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

DimbtFormatAsLabelFormatDocument =

btEngine.Documents.Open(\)

' Change the number of identical labels and serialized labels to print btFormat.PrintSetup.NumberOfSerializedLabels = 4 btFormat.PrintSetup.IdenticalCopiesOfLabel = 10 ' 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 number of serialized labels and identical copies is changed, and the label is printed.

Printing to a Different Printer

Selecting a printer to print label formats can be accomplished in two different ways:

?

Specifying the printer when opening a label format

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