Create barcode with font Free 3 of 9

public Bitmap CreateBarcode(string data)
{
    data = "55536"; 
    string barcodeData = "*" + data + "*";
    Bitmap barcode = new Bitmap(1, 1);
    Font threeOfNine = new Font("Free 3 of 9 Extended", 31, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);

    Font arial = new Font("Arial", 13,
              System.Drawing.FontStyle.Regular,
              System.Drawing.GraphicsUnit.Point);

    Graphics graphics = Graphics.FromImage(barcode);
    SizeF dataSize = graphics.MeasureString(barcodeData, threeOfNine);
    dataSize.Height = 70;

    barcode = new Bitmap(barcode, dataSize.ToSize());
    graphics = Graphics.FromImage(barcode);

    graphics.Clear(Color.White);
    graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;

    graphics.DrawString(barcodeData, threeOfNine, new SolidBrush(Color.Black), 0, 0);

    graphics.DrawString(data, arial, new SolidBrush(Color.Black), 50, 40);

    graphics.Flush();

    threeOfNine.Dispose();
    graphics.Dispose();

    return barcode;
}

I am generating a barcode with the above code, but my scanner cannot read the barcode (for 55536). BUT, if I switch the data value to "1111" or "2222", then the barcode will be read very well. so I think this is not a scanner problem, does anyone know what is wrong with this code? please advice.

+5
source share
3 answers

If you use only numbers, you can try 3 out of 9 basic fonts (without extension). Print the same barcode from "Write" and compare them to see if your solution is building a complete barcode or if it is truncated.

+3
source

1. , "*", , -, . 2. , . . 3. , . . - -. : - asp.net 3 9.

0

try the prefix and suffix:

why are you transferring data to

public Bitmap CreateBarcode(string data)
{
    data="55536"; //dont pass the data from here pass it from outside method for eg. call it   from the        button click or whatever control you are using.
}
-2
source

All Articles