EAN 8/13 Code 39/128 Barcode Creator

A couple of weeks ago I saw this post on Mibuso. This got my attention because this solution to make barcodes required no extra hassle with external components or fonts. A BMP containing the barcode is made using OutStreams, pretty neat stuff!

So I’ve started to use this piece of code to make barcodes of the type EAN8, EAN13, Code 128 & Code 39. In brief, all barcodes that I’ve already used in my (short) career.

A test with my mobile phone (Android :) ) and a handheld scanner quickly learned me that the barcodes were readable. At this point I decided to upload my code to Mibuso, and like this my first personal download on Mibuso is a fact!

Many thanks to Igor Pchelnikov for his initial post on Mibuso and the help he offered me to achieve this!

You can find the source code here: http://mibuso.com/dlinfo.asp?FileID=1192

All comments are off course more than welcome, this also counts for ratings. :)

10 Responses to “EAN 8/13 Code 39/128 Barcode Creator”

  1. Hi lyot,

    I also had the requirement to produce barcodes on NAV. And your solution is great!!
    I have used this solution too http://mibuso.com/dlinfo.asp?FileID=1043
    but I had to produce Code128-Barcodes as well.
    I recognized a few problems when using your code: when initialising the table for Code128-encoding there is missing the entry for the value 66.
    I also got a problem when trying to read the produced barcode: there was an error in calculating the WeightSum. My barcode only exitst of numbers (e.g. 1000910736) and the WeightSum and hence the CheckDigit have been wrong.
    Perhaps you can have a look at these two things.

    Best regards
    Thomas

  2. Sure thing!

  3. Version v1.1:
    - Missing Code128 for value 66
    - Bugfix in checksum calculation for Code 128

  4. Fix size (DPI), so it is very fast to scale up/down the picture

    In function CreateBMPHeader add code to start

    PS := ROUND(2835 / pintSize,1,’=');
    pintSize := 1;

    And change code

    From:
    poutBmpHeader.WRITE(2835, 4); //HORIZONTAL RESOLUTION
    poutBmpHeader.WRITE(2835, 4); //VERTICAL RESOLUTION

    To:

    poutBmpHeader.WRITE(PS, 4); //HORIZONTAL RESOLUTION
    poutBmpHeader.WRITE(PS, 4); //VERTICAL RESOLUTION

  5. Yep, had some troubles with scaling up the picture & performance.
    I will try your solution for a next release.
    Thanks for the tip!

  6. Hello, i would like to thank you, your code works great. While testing i believe i found an error with the encoding for precTmpCode128.CharC := ‘84′;

    //precTmpCode128.Encoding := ‘10111100100′;
    precTmpCode128.Encoding := ‘10011110100′;

    Best regards

  7. Thanx for reporting the bug!
    I’ll try to bring out an update this weekend.

  8. v1.2 :
    - Wrong Code128 for value 84
    - Performance fix for scaling barcode

  9. Hallo,

    Thank you for your source. The EAN13 code we use have 13 characters so I cut the last one to use it in your function EncodeEAN13 (I believe the last one is the checksum). That works for numbers like 4260061920112. I get a barcode that I can scan en it return the same number. When I use a number like 8710871087995 it prints a barcode witch I cant scan any more. Can you tell me what do I wrong.

    Lex

  10. Hi Lex,

    You’re doing nothing wrong, this probably an encoding bug.
    I’ll try to fix this this weekend.
    This new version will also enable to print bar codes vertical.

Leave a Reply

*
To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
Click to hear an audio file of the anti-spam word

Create a new blog and join in the fun!