Generate Barcodes With The Zebra-Barcode_Upca Font And The Printdocument Object Follow

0
Avatar
Legacy Poster

I have a client using an old VB6 program and Seagull’s Zebra print drivers to generate UPC barcodes with the ‘Zebra-Barcode_UPCA’ font. The client is currently running Bartender 7.2.
 
For example (VB6):
Private Sub print_Click()
   Dim upc As String = "012345678905"
   Printer.FontName = "Zebra-BarCode_UPCA"
   Printer.FontSize = 24
   Printer.CurrentX = 20
   Printer.CurrentY = 20
   Printer.Print upc
   Printer.NewPage
   Printer.EndDoc
End Sub
 
The client wants the program updated to the .NET Framework using C# and Bartender 9.2. However, the font does not generate a barcode using the PrintDocument object. It just prints plain text. 
 
For example (C#):
private void print_Click(object sender, EventArgs e)
{
    PrintDocument printDocument = new PrintDocument();
    printDocument.PrintPage += new PrintPageEventHandler(this.PrintPageEventHandler);
    printDocument.Print();
}
 
private void PrintPageEventHandler(object sender, PrintPageEventArgs ev)
{
    String upc = "012345678905";
    Font font = new Font("Zebra-BarCode_UPCA", 24);
    float currentX = 20.0F;
    float currentY = 20.0F;
    ev.Graphics.DrawString(upc, font, Brushes.Black, currentX, currentY, new StringFormat());
}
 
The client has Bartender Label formats in place for other labels, but in this particular case the output needs to be created at run time. This application generates a label that contains 1 to 13 barcoded items depending on the contents of the box.
 
Is it possible to generate barcodes with the Zebra barcode fonts and the PrintDocument object? It not, is there another way to create barcoded output at run time? 
 
 

3 comments

0
Avatar
Domingo Rodriguez
Moderator
Comment actions Permalink

When automating BarTender you've no need to use bar code fonts for printing bar codes. You can use a proper bar code object instead and assign its variable value by using named sub-strings. You will find a full reference on our .NET SDK by opening BarTender's Help (within BarTender, press the F1 key to open BarTender's Help) by visiting the "Automating BarTender > Automation with the BarTender .NET SDKs"

0
Avatar
Legacy Poster
Comment actions Permalink

Thanks Domingo for you quick response.
 
I’ve reviewed the SDK documentation again and I don’t see how a barcode object can be added to a format at run time. It looks like a label format with predefined barcode objects must exist before it can be opened using the SDK (I am using the 9.2 version of SDK, so maybe it is outdated).
 
Unfortunately, I don’t know how many barcodes need to be printed on a label, until my application is running. So designing a label in advance won’t really work, until I create a format for each combination of barcodes. 
 
For example:
Format1 = Has 1 barcode
Format2 = Has 2 barcodes
Format3 = Has 3 barcodes
Format4 = Has 4 barcodes
Format5 = Has 5 barcodes
 
and so on...
 
Let me ask this another way. Is it possible to create a label format and add one or more barcode objects to it, using just the SDK?
0
Avatar
Domingo Rodriguez
Moderator
Comment actions Permalink

No, BarTender's .NET SDK doesn't support full object automation at the moment. You're not allowed to create BarTender objects directly via the .NET SDK.

 

What you could make use of is our Template and Layer features in BT v10.0 and v10.1 respectively. This way, one BT document can have multiple templates (conditionally selectable at print time), and each template can have multiple layers (conditionally selectable at print time). This will help you to print BT documents with 1-5 bar codes.

 

http://www.bartenderbarcodesoftware.com/label-software/whitepapers/WhitePaper_WhatsNewInBT101.pdf

 

Hope this helps.

Please sign in to leave a comment.