Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8155709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:44:40+00:00 2026-06-06T16:44:40+00:00

It was easy to generate a 3 of 9 barcode using Font() Font f

  • 0

It was easy to generate a 3 of 9 barcode using Font()

Font f = new Font("Free 3 of 9", 80);
this.Font = f;

Label l = new Label();
l.Text = "*STACKOVERFLOW*";
l.Size = new System.Drawing.Size(800, 600);
this.Controls.Add(l);

this.Size = new Size(800, 600);

Its working. I see the barcode and Im able to scan it. Now I would like to use something else, like Code 128 For that I need to install the Font (done) and just change

Font f = new Font("Free 3 of 9", 80); to Font f = new Font("Code 128", 80);

After that I see a barcode on my window. The problem is that Im not able to scan that. And I think thats because I dont use the right start and stop tag for the barcode. As I understood there have to be always a start/stop char or whatever. For 3 of 9 ist the * for Code 128 im not sure. On wiki there is Start Code A so I tried

Font f = new Font("<Start Code A>test<Stop>", 80);, Font f = new Font("<Start Code A>test<Stop Code A>", 80); and so on… Im not able to scan the output. Because the scanner cannot find the start and stop char. Any ideas? Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:44:43+00:00Added an answer on June 6, 2026 at 4:44 pm

    Code 128 can be represented with a font totally fine. It’s trickier than 3 of 9 though because you have to include a checksum character at the end which needs to be dynamically computed based on the content of the barcode. There are also 3 different versions which each have a different start char.

    In other words the barcode needs to be laid out like:

    [start char][barcode][checksum][stop char]
    

    The benefit of code128 is that it is much more concise than 3 of 9.

    This page helped me work out the algorithm to compute my checksums.

    A very general overview of the algorithm is:

    1. Each character of the barcode gets a specific value assigned to it
      depending on what the character is and where it is located in the
      barcode.

    2. All of the values in 1) above are added together.

    3. Get the modulus 103 value of the total in 2) above.

    4. In most cases, the checksum char will be the ASCII code for: (modulus value
      plus 32) as determined in 3) above.

    There were some nuances, I ended up needing to create this algorithm in javascript of all things (no questions). For my own future reference and to show some of the nuances this is what it looked like:

    /*
     * This is the variable part of my barcode, I append this to a 
     * static prefix later, but I need to perform logic to compute the 
     * checksum for this variable. There is logic earlier that enforces 
     * this variable as a 9 character string containing only digits.   
     */ 
    var formIncrement = // a 9 char "digit" string variable
    
    /*
     * Dynamically compute the total checksum value (before modulus) 
     * for the variable part of my barcode, I will need to get a modulus 
     * from this total when I am done. If you need a variable number of 
     * characters in your barcodes or if they are not all digits 
     * obviously something different would have to be done here.  
     */ 
    var incrementCS = ((parseInt(formIncrement.charAt(0)) + 16) * 7) +
                      ((parseInt(formIncrement.charAt(1)) + 16) * 8) +
                      ((parseInt(formIncrement.charAt(2)) + 16) * 9) +
                      ((parseInt(formIncrement.charAt(3)) + 16) * 10) +
                      ((parseInt(formIncrement.charAt(4)) + 16) * 11) +
                      ((parseInt(formIncrement.charAt(5)) + 16) * 12) +
                      ((parseInt(formIncrement.charAt(6)) + 16) * 13) +
                      ((parseInt(formIncrement.charAt(7)) + 16) * 14) + 
                      ((parseInt(formIncrement.charAt(8)) + 16) * 15);
    
    /*
     * 452 is the total checksum for my barcodes static prefix (600001), 
     * so it doesn't need to be computed dynamically, I just add it to 
     * the variable checksum total determined above and then get the 
     * modulus of that sum:  
     */ 
    var checksum = (452 + incrementCS) % 103
    
    
    var barcode = "š600001" + formIncrement
    
    /*
     * The 0 and the 95 - 102 cases had to be defined explicitly because 
     * their checksum figures do not line up with the javascript char 
     * codes for some reason (see the code 128 definition table in the 
     * linked page) otherwise we simply need to get the charCode of the 
     * checksum + 32. I also tack on the stop char here. 
     */ 
    switch (checksum) {
        case 0 :
        barcode += "€œ";
        break;
        case 95 :
        barcode += "‘œ";
        break;
        case 96 :
        barcode += "’œ";
        break;
        case 97 :
        barcode += "“œ";
        break;
        case 98 :
        barcode += "”œ";
        break;
        case 99 :
        barcode += "•œ";
        break;
        case 100 :
        barcode += "–œ";
        break;
        case 101 :
        barcode += "—œ";
        break;
        case 102 :
        barcode += "˜œ";
        break;
        default :
        barcode += String.fromCharCode(checksum + 32) + "œ";
    }
    
    return barcode;
    

    You may notice that my start and stop chars in my example (š, œ) don’t seem to match up with the ones shown on the linked page. If I remember I think it was because I had some non-standard code128 font and these chars translated to the correct ones.

    EDIT

    I checked back in my documentation. It looks like I got the font from right here. With that font specifically and using the algorithm above, I just made a code128b barcode for test which came out to štestwœ, it scanned fine. Your checksum algorithm seems to be working fine because we both have w but it looks like your start and stop codes are off if you are getting: ÌtestwÎ.

    I made a point to look for the same barcode font that I am using because I have a feeling that different brands of code128 fonts may implement different characters to represent the start and stop barcodes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using JAXB in Java it is easy to generate from a xml schema file
I am using iText to generate some PDF documents. It is quite easy to
Is there an easy way to generate docs for REST api direct from a
Is there an easy way to generate a labeled bitmap image for each glyph
Is there an easy way to generate a log file that will trace at
I'm looking for an easy way to generate previews for labels generated as pdfs.
I was wondering if is there an easy way to generate views from form
In cases where order does matter, it's rather easy to generate the matrix of
Is there an easy way to generate table of contents with links to corresponding
I know this exists django-admin.py inspectdb > models.py However, is there an easy way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.