1/20/2013

Barcode design in C#

Barcode design in C#
Barcode design in C#

  using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  using System.IO;
  using System.Drawing.Imaging;
  private void txt_Barcode_TextChanged(object sender, EventArgs e)  
     {  
       if (txt_Barcode.TextLength > 0)  
       {  
         Barcodepreview(txt_Barcode.Text.ToString());  
       }  
       else  
       {  
         pic_Barcodepreview.Image = null;  
       }  
     }  
     private void Barcodepreview(string barcodeno)  
     {  
       string barcode = barcodeno;  
       Bitmap bmp = new Bitmap(450, 450);  
       using (Graphics g = Graphics.FromImage(bmp))  
       {  
         Font f = new System.Drawing.Font("IDAutomationHC39M", 14);  
         PointF point = new PointF(2f, 2f);  
         SolidBrush black = new SolidBrush(Color.Black);  
         SolidBrush white = new SolidBrush(Color.White);  
         g.FillRectangle(white, 0, 0, bmp.Width, bmp.Height);  
         g.DrawString(barccode.ToString(), f, black, point);  
       }  
       using (MemoryStream ms = new MemoryStream())  
       {  
         pic_Barcodepreview.Image = bmp;  
         pic_Barcodepreview.Height = bmp.Height;  
         pic_Barcodepreview.Width = bmp.Width;  
       }  
     }  

Download Font

No comments:

Post a Comment