Generating Label Using .net
Hello,
I am using first time bartender application to generate label from our asp.net/vb.net environment. I have so far looked at the .net sdk way of printing and created a small application. I have couple of questions though,
1) start bartender engine
2) create label format object link to a format
3) specify substring name and value data mapping
4) specify printer
5) print
6) stop/close the engine
question 1:
This above prints only one label, if you want to continue printing multiple labels by specifiying multiple substring values, do you do this between the 1st and 5th step as following.
1) start bartender engine
2) create label format object link to a format
3) specify substring name and value data mapping (note: This data is coming from some query in ado.net and looping thru it to map to the substring on the format)
4) specify printer
5) print
--REPEAT STEP 2 TO 5 again in loop to print more labels?
6) stop/close the engine
Question 2:
Is this the only thing needed to print. Would this handle multiple vb.net programs printing multiple formats with different data. Do I need to worry about task queue printing like this?
Question 3:
Is .net component allows you to drop a data file, is there a dll to create a data file that can be picked up by bartender and printed to a printer? If so how do you create a file from .net classes
Thanks
Following is the sample for reference...
btEngine.Start()
Dim messages As Seagull.BarTender.Print.Messages = Nothing
Dim str As String = "c:\bartender\mylabel.btw"
Dim labelFormatDocument As LabelFormatDocument = btEngine.Documents.Open(str)
For Each tstr As Seagull.BarTender.Print.SubString In labelFormatDocument.SubStrings
Console.WriteLine("SubString Name: " & tstr.Name & ", SubString Type: " & tstr.Type & ", SubString Value: " & tstr.Value)
'labelFormatDocument.SubStrings.SetSubString("name", "value")
Next
labelFormatDocument.PrintSetup.PrinterName = "Printer path \\server\printer"
messages = Nothing
Dim waitForCompletionTimeout As Integer = 10000 ' 10 seconds
Dim result As Result = labelFormatDocument.Print("test", waitForCompletionTimeout, messages)
Dim messageString As String = Constants.vbLf + Constants.vbLf & "Messages:"
For Each message As Seagull.BarTender.Print.Message In messages
messageString &= Constants.vbLf + Constants.vbLf + message.Text
Next message
If result = Result.Failure Then
MessageBox.Show(Me, "Print Failed" & messageString, "test")
Else
MessageBox.Show(Me, "Label was successfully sent to printer." & messageString, "test")
End If
' Close all open formats.
btEngine.Documents.CloseAll(SaveOptions.SaveChanges)
' Stop the BarTender print engine.
btEngine.Stop()
-
Modifying named sub-strings currently requires you to follow exactly the steps you've followed if the data on the label needs to change for every label that prints. If you want to send variable data for several labels in one go, you will need to connect your BT document to a text database file (you would create and fill before):
Imports Seagull.BarTender.Print.Database
' Application Code
' ...
Dim btEngine As New Engine()
' Start a BarTender print engine
btEngine.Start()
' Open a label format
Dim btFormat As LabelFormatDocument = btEngine.Documents.Open("c:\MyLabel.btw")
' Set the TextFile database connection file name
CType(btFormat.DatabaseConnections("TextFileDB"), TextFile).FileName = "c:\NutritionInformationEurope.txt"
' Print the label format document
btFormat.Print()
' Stop the engine
btEngine.Stop()
Creating a text file with the variable data to be printed is not part of our .NET SDKs, this is part of standard VB .NET IO Dlls.
0 -
Legacy Poster
★ BarTender Hero ★
Thank you that helped. I want to clarify some things.
most of the time we have one format and data is changing.
1) That means between engine start and end, I can do that without loop , speicify label format and data using file instead of loop.
Printing to printer, although requires printers to be active. Otherwise throws an error.
2) Using file, does that require developer to include bartender command in the beginning of the file, like commander program? Or just pure data file like following? and do all the other setting using code as
--set label path Dim btFormat As LabelFormatDocument = btEngine.Documents.Open("c:\MyLabel.btw")
-->set printer
File:
"Name1", "Address1", "ZipCod1e", "ProductCode1", "Product Description1"
"Name2", "Address2", "ZipCode2", "ProductCode2", "Product Description2"
"Name3", "Address3", "ZipCode3", "ProductCode3", "Product Description3"
Would this still communicate to printer directly or this can generates the file for commander application?
3) if I am using commander app
create a file and drop it using .net IO. and hardcode the command line in the beginning of the file. Drop the file where bartender is monitoring to pick up? Do I have to hardcode the command line in the beginning? or there is a way to create that command using code?
Thanks
Dipti
Thanks
Dipti
0 -
1. Yes, between engine start and end you can have BarTender read from a text file. It will generate one print job being sent to the printer. This is the same as if you would connect your BarTender document to a database file via BarTender's "File > Database Connection Setup" dialog.
2. It just requires you to format it as pure data (you might wish to use a database header with the names of the database fields). Basically, at print time you've to use the same data format as you're using at design time for connecting your BT document to the "sample database" (this is required). The structure of the sample database and the one you use at print time has to be the same.
3. Commander can recognize several types of trigger files:
- Trigger files with just data on it --> In which case you would use a "BarTender" command in Commander.
- Trigger files with a Commander Script header and footer --> In which case you would use a "Commander Script" command in the Commander task.
- Trigger files in XML format --> In which case you would use "BTXML Script" (and sometimes also the "Transform" command) in the Commander task
I suggest you to take a look at Commander's White Papers as well:
Commander:
Commander Examples:
http://www.bartenderbarcodesoftware.com/label-software/whitepapers/Commander-Examples(English).pdf
0 -
Legacy Poster
★ BarTender Hero ★
Hi got it. Thanks.
With .net label printing, reading textfile and printing multiple labels, would using task queue makes it better that program doesn't have to wait for it to finish printing from printer?
How does the task queue and starting multiple engine works parallel? submitting task is still sequential so how does multiple engine works with queued tasks.
Thanks
Dipti
0 -
You've two methods for sending tasks to the TaskQueue:
TaskQueue.QueueTask --> This method is asynchronous and won't wait for the task to finish.
TaskQueue.QueueTaskandWait --> This method is synchronous and will wait for the task to finish until processing the next one.
In your case, please note that the print job which corresponds to all records of your database is just one task. If you plan to simultaneously print several BT documents which read from different database text files, then yes, running multiple engines will result in a benefit. If you would e.g. make use of TaskQueue.QueueTask() method, the task will be submitted to the Task Queue and immediately after (without waiting for the task to finish), another task will be submitted to the queue. Print job order won't be guaranteed
I advice you to take a look at BarTender's Help as our .NET SDK documentation is very complete and helpful on this. Just open BarTender, press the F1 key and visit the "Automating BarTender > Automation with the BarTender .NET SDKs > BarTender .NET Print Server SDK > Getting Started" topic.
0
請登入寫評論。
評論
5 條評論