Hello everyone,
i am working on barcode generate in C#.net technology i am having CODE 39
here is the code
private Bitmap CreateBarcode(string _data) //_data like “123456”
{
string barcodeData = “" + _data + "”;
Bitmap barcode = new Bitmap(1, 1);
// less than size 40, my barcode reader can not read it.
Font threeOfNine = new Font(“Free 3 of 9”, 40,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point);
Font arial = new Font(“Arial”, 15,
System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Pixel);
Graphics graphics = Graphics.FromImage(barcode);
SizeF dataSize = graphics.MeasureString(barcodeData, threeOfNine);
dataSize.Height = 60;
barcode = new Bitmap(barcode, dataSize.ToSize());
graphics = Graphics.FromImage(barcode);
graphics.Clear(Color.White);
graphics.TextRenderingHint = System.Drawing.Text.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;
}
"what changes should i do to make the above code compatible with CODE 128"
Any help will be appreciable
Thank you
BarCodeBuilder builder = new BarCodeBuilder();
//code text font's type and size
builder.CodeTextFont = new System.Drawing.Font("Verdana", 12f);
//Set the symbology type to Code128
builder.SymbologyType = Symbology.Code128;
//Set the Code text for the barcode
builder.CodeText = "1234567";
//Increase the space between code text and barcode to 1 point
builder.CodeTextSpace = 1.0f;
//Set the Code text for the barcode
builder.CodeText = "1234567";
//Align the code text to center
builder.CodeTextAlignment = System.Drawing.StringAlignment.Center;
//Set the location of the code text to above the barcode
builder.CodeLocation = CodeLocation.Above;
//Set the code text fore color to red
builder.CodeTextColor = System.Drawing.Color.Red;
//Save the image to your system and set its image format to Jpeg
builder.Save("barcode.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
Thanks for replying
While running this code it is showing following error
"BarCodeBuilder builder = new BarCodeBuilder(); "
The type or namespace name ‘BarCodeBuilder’ could not be found (are you missing a using directive or an assembly reference?)
" builder.SymbologyType = Symbology.Code128; "
The name ‘Symbology’ does not exist in the current context
Thank You
Hi Ikram ul Haq,
while running the code it is showing “Aspose” watermark.
how and what is the procedure to remove that watermark.
Thank you