?
Solved

Printing barcodes using zebra printer

Posted on 2008-11-18
15
Medium Priority
?
1,788 Views
Last Modified: 2012-05-05
I need to create a windows form application in VB.Net to print barcodes on zebra printer(Z4MPlus).
I have controls where the user can select the item and enter the number of barcodes for that item.
When user clicks on Print button, barcodes should should be printed with the barcode and the item number below it. Please tell me how do I do this.
0
Comment
Question by:SGUDAPAT
  • 6
  • 4
  • 4
  • +1
15 Comments
 
LVL 6

Accepted Solution

by:
AdnanKurtovic earned 600 total points
ID: 22987512
Easiest way is to use barcode font. Those lines on barcode just represent number written below, so using this font you will actually print it just like any other text.
0
 
LVL 1

Author Comment

by:SGUDAPAT
ID: 22987554
Do I need to purchase any software for Barcode font?
Can please give me small example what you mean by barcode font.
0
 
LVL 16

Assisted Solution

by:HooKooDooKu
HooKooDooKu earned 600 total points
ID: 22987954
By a barcode font, it's ment a font that outputs in a barcode.  Think of a WingDings font, but rather than fancy shapes, the font draws the lines a particular barcode uses.

There are definitly barcode fonts for sale.  Don't know if you can find any freeware bar code fonts.

Otherwise, if you know how to draw boxes on the printer, it's possible to produce you're own barcodes if you know the secifications for the font you desire.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:SGUDAPAT
ID: 22987980
I donot want to use any purchased software, I write code to generate barcodes using Vb.Net code.
0
 
LVL 1

Author Comment

by:SGUDAPAT
ID: 22987989
I donot want to use any purchased software, I want to write  code to generate simple barcodes(which can be read by the scanner) using Vb.Net cod
0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 22988078
Then the first step is being able to draw boxes.  Do you know how to do that?
The next step is going to be learning the specification for the barcode you want to print.  There are several types of barcodes out there.  Just a few examples I've heard of include 2-of-5 and 3-of-9 and have different ranges of what can be printed.  As an example 3-of-9 can print 0-9, A-Z (no lower case), and the symbols *-.$/+% and <Space>.  Others can only print numbers 0-9.  Then there is the UPC Barcode specfication.  Some specifications you can find on the internet for free.  Others, it seems the only way to learn the specification is to BUY them from one of the standards committees (I know we've done that before to be able to print our own OCR font).

The only barcode specification I could help you with at all would be the 3-of-9.
0
 
LVL 1

Author Comment

by:SGUDAPAT
ID: 22988136
I haven't written any barcodes application prior to this, this is my first application.
The user for whom I am writing this application doesn't have any specification about the barcodes, the only thin the user is concerns is that the barcodes cshoudl be printed using zebra printer(Z4MPlus). so please help with the 3-of-9.
0
 
LVL 1

Author Comment

by:SGUDAPAT
ID: 22988142
I haven't written any barcodes application prior to this, this is my first application.
The user for whom I am writing this application doesn't have any specification about the barcodes, the only thing the user is concerns is that the barcodes should be printed using zebra printer(Z4MPlus). so please help with the 3-of-9.
0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 22989538
Here's what I can tell you about the basics 3-of-9:
Dimensions:
The optimum Height of the barcode is 0.4 inches.
The optimum Narrow Bar/Space Width is 0.01 inches.
The optimum Wide Bar/Space Width is 0.03 inches.
The bar code should start and end with a '*' symbol (so to print "123", you really print "*123*").
The code snippet below, written in VB6, draws a barcode for the given Code39 String at the given X,Y coordinates on the page.  The GoSubs Dash, Dott, Deep, and Dixx sort of defines the encoding for each character.
The GoSub Dash would draw a Wide Bar and move the distance of a Narrow Space.
The GoSub Dott would draw a Narrow Bar and move the distance of a Narrow Space.
The GoSub Deep would draw a Wide Bar and move the distance of a Wide Space.
The GoSub Dixx would draw a Narrow Bar and move the distance of a Wide Space.

The code snippet utilizes additional logic that is beyond the scope of this snippet and the implementation for which can not be provided.  However, it should suffice to say that 'Brush as clsAPIBrush' and 'R as RectDbl' implement API Brush and Rectangle objects with coordinates in decimal inches (i.e. coordinates are floating point doubles where 1.0 equals one inch).  The function and property names shown in the code should suffice to indicate what the logic is doing with these objects.

Below the example is an attempt to "Draw" a barcode with ASCII characters for the string "123".

Public Sub PrintCode39BarCode(ByVal hDC As Long, Code39 As String, X As Double, Y As Double)
Dim BarLength As Double             'Size (Height) of a Bar
Dim DotWidth As Double              'Size (Width) of a Dot      (0.01)
Dim DashWidth As Double             'Size (Width) of a Dash     (0.03)
Dim FudgeWidth As Double
 
    'Initialize Dimentions
    BarLength = 0.4
    DotWidth = 0.01
    DashWidth = 0.03
    FudgeWidth = 2# / CDbl(GetDeviceCaps(hDC, LOGPIXELSX))  'API Function Call
    
Dim BarCode As String       'String of what to Print
Dim I As Long
 
    'Insert Start/Stop Char
    BarCode = "*" & Code39 & "*"
    
PrintBarCode:
Dim Brush As clsAPIBrush    'Personal Implementation of API Brush
Dim R As RectDbl            'Rectangle UDT with floating point (double) coordinates
    
    Set Brush = New clsAPIBrush
        
    With R
        .Left = X
        .Bottom = Y
        .Right = X
        .Top = .Bottom - BarLength
    End With
    
    'Draw the Code 39
    For I = 1 To Len(BarCode)
        Select Case Mid$(BarCode, I, 1)
            'DASH = "### ", DOTT = "# ", Deep = "###   ", DIXX = "#   "
            Case "*": GoSub Dixx: GoSub Dott: GoSub Dash: GoSub Dash: GoSub Dott    'Start/Stop Char
            Case "0": GoSub Dott: GoSub Dixx: GoSub Dash: GoSub Dash: GoSub Dott
            Case "1": GoSub Dash: GoSub Dixx: GoSub Dott: GoSub Dott: GoSub Dash
            Case "2": GoSub Dott: GoSub Deep: GoSub Dott: GoSub Dott: GoSub Dash
            Case "3": GoSub Dash: GoSub Deep: GoSub Dott: GoSub Dott: GoSub Dott
            Case "4": GoSub Dott: GoSub Dixx: GoSub Dash: GoSub Dott: GoSub Dash
            Case "5": GoSub Dash: GoSub Dixx: GoSub Dash: GoSub Dott: GoSub Dott
            Case "6": GoSub Dott: GoSub Deep: GoSub Dash: GoSub Dott: GoSub Dott
            Case "7": GoSub Dott: GoSub Dixx: GoSub Dott: GoSub Dash: GoSub Dash
            Case "8": GoSub Dash: GoSub Dixx: GoSub Dott: GoSub Dash: GoSub Dott
            Case "9": GoSub Dott: GoSub Deep: GoSub Dott: GoSub Dash: GoSub Dott
            Case "A": GoSub Dash: GoSub Dott: GoSub Dixx: GoSub Dott: GoSub Dash
            Case "B": GoSub Dott: GoSub Dash: GoSub Dixx: GoSub Dott: GoSub Dash
            Case "C": GoSub Dash: GoSub Dash: GoSub Dixx: GoSub Dott: GoSub Dott
            Case "D": GoSub Dott: GoSub Dott: GoSub Deep: GoSub Dott: GoSub Dash
            Case "E": GoSub Dash: GoSub Dott: GoSub Deep: GoSub Dott: GoSub Dott
            Case "F": GoSub Dott: GoSub Dash: GoSub Deep: GoSub Dott: GoSub Dott
            Case "G": GoSub Dott: GoSub Dott: GoSub Dixx: GoSub Dash: GoSub Dash
            Case "H": GoSub Dash: GoSub Dott: GoSub Dixx: GoSub Dash: GoSub Dott
            Case "I": GoSub Dott: GoSub Dash: GoSub Dixx: GoSub Dash: GoSub Dott
            Case "J": GoSub Dott: GoSub Dott: GoSub Deep: GoSub Dash: GoSub Dott
            Case "K": GoSub Dash: GoSub Dott: GoSub Dott: GoSub Dixx: GoSub Dash
            Case "L": GoSub Dott: GoSub Dash: GoSub Dott: GoSub Dixx: GoSub Dash
            Case "M": GoSub Dash: GoSub Dash: GoSub Dott: GoSub Dixx: GoSub Dott
            Case "N": GoSub Dott: GoSub Dott: GoSub Dash: GoSub Dixx: GoSub Dash
            Case "O": GoSub Dash: GoSub Dott: GoSub Dash: GoSub Dixx: GoSub Dott
            Case "P": GoSub Dott: GoSub Dash: GoSub Dash: GoSub Dixx: GoSub Dott
            Case "Q": GoSub Dott: GoSub Dott: GoSub Dott: GoSub Deep: GoSub Dash
            Case "R": GoSub Dash: GoSub Dott: GoSub Dott: GoSub Deep: GoSub Dott
            Case "S": GoSub Dott: GoSub Dash: GoSub Dott: GoSub Deep: GoSub Dott
            Case "T": GoSub Dott: GoSub Dott: GoSub Dash: GoSub Deep: GoSub Dott
            Case "U": GoSub Deep: GoSub Dott: GoSub Dott: GoSub Dott: GoSub Dash
            Case "V": GoSub Dixx: GoSub Dash: GoSub Dott: GoSub Dott: GoSub Dash
            Case "W": GoSub Deep: GoSub Dash: GoSub Dott: GoSub Dott: GoSub Dott
            Case "X": GoSub Dixx: GoSub Dott: GoSub Dash: GoSub Dott: GoSub Dash
            Case "Y": GoSub Deep: GoSub Dott: GoSub Dash: GoSub Dott: GoSub Dott
            Case "Z": GoSub Dixx: GoSub Dash: GoSub Dash: GoSub Dott: GoSub Dott
            Case "-": GoSub Dixx: GoSub Dott: GoSub Dott: GoSub Dash: GoSub Dash
            Case ".": GoSub Deep: GoSub Dott: GoSub Dott: GoSub Dash: GoSub Dott
            Case " ": GoSub Dixx: GoSub Dash: GoSub Dott: GoSub Dash: GoSub Dott
            Case "$": GoSub Dixx: GoSub Dixx: GoSub Dixx: GoSub Dott: GoSub Dott
            Case "/": GoSub Dixx: GoSub Dixx: GoSub Dott: GoSub Dixx: GoSub Dott
            Case "+": GoSub Dixx: GoSub Dott: GoSub Dixx: GoSub Dixx: GoSub Dott
            Case "%": GoSub Dott: GoSub Dixx: GoSub Dixx: GoSub Dixx: GoSub Dott
        End Select
    Next I
 
    Set Brush = Nothing
    Exit Sub
 
Dash:
    With R
        .Right = .Left + DashWidth - FudgeWidth
        Call Brush.FillRect(hDC, R)
        .Left = .Right + DotWidth + FudgeWidth
    End With
    Return
    
Dott:
    With R
        .Right = .Left + DotWidth - FudgeWidth
        Call Brush.FillRect(hDC, R)
        .Left = .Right + DotWidth + FudgeWidth
    End With
    Return
    
Deep:
    With R
        .Right = .Left + DashWidth - FudgeWidth
        Call Brush.FillRect(hDC, R)
        .Left = .Right + DashWidth + FudgeWidth
    End With
    Return
 
Dixx:
    With R
        .Right = .Left + DotWidth - FudgeWidth
        Call Brush.FillRect(hDC, R)
        .Left = .Right + DashWidth + FudgeWidth
    End With
    Return
    
End Sub
 
'This code shoudld draw a barcode for the string "123" that looks something like this:
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
#      #  ###  ###  #  ###  #      #  #  ###  #  ###      #  #  ###  ###  ###      #  #  #  #      #  ###  ###  #
 
<- Here is the '*' ---><- Here is the '1'----><- Here is the '2'----><- Here is the '3'----><- Here is the '*' ->

Open in new window

0
 
LVL 6

Expert Comment

by:AdnanKurtovic
ID: 22994355
Like I said, easiest way is to use barcode font. You can download FREE one here:
http://www.barcodesinc.com/free-barcode-font/

How to generate it? Easy. Let's say your product barcode number (number that is located just beneath barcode lines) is 123456789. So you will write 123456789 using any font (Arial, ...) and then change font to Code 39 Font TrueType that you download from site above. You can try this in Word. You will see barcode lines. That is it. In VB just set Text box font in Text box where you write barcode number to be Code 39 Font TrueType and voila :D

Here is another one font if you dont like previous. It is also FREE:
http://freebarcodefonts.dobsonsw.com/code128font-download.html
0
 
LVL 6

Expert Comment

by:AdnanKurtovic
ID: 22994381
I have to note that HooKooDooKu barcode will be unreadable for most (maybe all) barcode scanners. It is nice idea to play with, but is impractical. This is my opinion from practice since barcode scanners are very sensitive.
0
 
LVL 16

Expert Comment

by:HooKooDooKu
ID: 22994771
I have to admit that with my first implementation, I was having a problem with getting the bars to be just the right size.  The issue you have to take into account is pixel size of your printer.  You can see in the code above that there is a 'FudgeWidth' factor that had to come into play to get the barcodes to actually print to just the right size, and this was required for a LaserJet printer printing at 300 or 600dpi.  I'm not familier with a Zebra Printer, so I don't know what if any different type of fudge factor would be needed to get the barcode to print at the appropriate dimensions.  

Obviously using a barcode font, all of that has already been calculated for you.  You only have to make sure the barcode font is included in your application.  An easier task to learn that to learn to draw boxes if you haven't learned to do that accurately.

The one other plus side to writing it yourself would be the fact that you state your only trying to get this to work on a single type of printer.  If Fudge Factors are required, at least you only have one machine to test and get it working with.
0
 
LVL 27

Assisted Solution

by:planocz
planocz earned 300 total points
ID: 23098151
Here is a link that has a sample example on how to print barcodes

http://www.experts-exchange.com/Microsoft/Development/Visual_Studio_Express/Q_23477644.html
0
 
LVL 6

Expert Comment

by:AdnanKurtovic
ID: 23208055
Author stated "I used ZPL manual to write the ZPL code for printing the labels using the zebra printer." but question actually was how to print barcodes. In thread there was multiple working solutions, but author at the end never not stated he tried nor solutions are not working, so I request points to be diveded between me and HooKooDooKu.
0
 
LVL 1

Author Closing Comment

by:SGUDAPAT
ID: 31517958
Thanks for replying back to me! I used the ZPL code in my program to print the barcodes.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question