This article will show you how you can create barcode label
in c# windows
application using font(.ttf) with above and below text. In this I have user
barcode code 128.
Some of my previous articles are as follows: How
To Get Enumerate Installed Fonts List In Your Computer Using C# Windows
Application, Copy
File In C# Windows Application, Blinking
Text in C#.Net Windows Application, Limit
OR Restrict Number of Characters in Textbox C#.Net In windows Application.
So for this article first we will create a new windows
application.
Now download the barcode font and add that font in bin
directory.
Now add the below code into your form.
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.Drawing.Text;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void Form1_Load(object
sender, EventArgs e)
{
PrivateFontCollection
pfc = new PrivateFontCollection();
pfc.AddFontFile(@"font\code128.ttf");
lblBarcode.Font = new Font(pfc.Families[0],
40, FontStyle.Regular);
}
}
}
|
In above code I have used PrivateFontCollection to read the
font. This will read font without installing font in the user machine.
Now we have done run the application to check the output.
0 comments:
Please let me know your view