Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to generate Barcode (code 128) with some text where items details will be displayed. I am able to generate an image of a Barcode (code 128) but unable to add text into it.
I've tried this following code to add text into that image; text has been added but while taking printout of that barcode nothing happens.

var bmp = Bitmap.FromFile(Application.StartupPath + "\\Barcode\\" + partno.Text + ".jpg");
           var newImage = new Bitmap(bmp.Width, bmp.Height + 50);
            var gr = Graphics.FromImage(newImage);
            gr.DrawImageUnscaled(bmp, 0, 0);
            Brush br = new SolidBrush(Color.Black);
            Font font1 = new Font("Arial", 8, System.Drawing.FontStyle.Bold);
            gr.DrawString(partno.Text, font1, br, 0, 75);
            Font font2 = new Font("Arial", 7, System.Drawing.FontStyle.Regular);
            gr.DrawString(txtname.Text, font2, br, 0, 95);
            Font font3 = new Font("Arial", 7, System.Drawing.FontStyle.Regular);
            gr.DrawString(txtdetails.Text, font3, br, 0, 105);
            Font font4 = new Font("Arial", 8, System.Drawing.FontStyle.Bold);
            gr.DrawString("Rs." + txtsellprice.Text, font4, br, 0, 115);
            newImage.Save(Application.StartupPath + "\\Barcode\\" + partno.Text + "1.jpg");


Can anyone please give me code 128 Barcode font free download link so that i can generate the barcode using that font.
If anyone has some other idea please share.

Thanks in advance.
Posted
Updated 14-Jan-13 18:05pm
v2
Comments
Shanu2rick 15-Jan-13 0:55am    
Why are trying to add text to an already generated Image?
Rather than, Draw a new image with both code and Text.
sahabiswarup 15-Jan-13 0:56am    
actually in that image i am generating a barcode for a Item, and i've to add Item price as well as details into it.
So how i can do that?
Shanu2rick 15-Jan-13 0:59am    
Don't make it complex. Simply generate BarCode along with the text.
And are you using Code 128 Barcode Generator/Library?
sahabiswarup 15-Jan-13 1:16am    
yes i am using one barcode generator library (OnBarcode.Barcode.WinForms) but it generates only barcode as an image nothing else. But i've to add text above or below of that barcode.

1 solution

 
Share this answer
 
Comments
sahabiswarup 15-Jan-13 2:52am    
thanks a lot; 5 from me.
Shanu2rick 15-Jan-13 3:04am    
You're Welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900