Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 14-Jan-13 19:03pm
Edited 14-Jan-13 19:05pm
v2
Comments
Shanu2rick at 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 at 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 at 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 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
sahabiswarup at 15-Jan-13 2:52am
   
thanks a lot; 5 from me.
Shanu2rick at 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)



Advertise | Privacy | Mobile
Web03 | 2.8.150129.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100