How to draw ISBN and other barcode in Winforms

Adam20110411

New member
Joined
Feb 16, 2012
Messages
1
Programming Experience
1-3
Download .NET ISBN Generator SDK Library for C#, VB.NET, ASP.NET

Right click .NET Visual Studio Toolbox, select menu Choose Items...

In "Choose Toolbox Items" form, click button "Browse...", and select dll OnBarcode.Barcode.WinForms.dll

After selection, you will find four items under "Components" section: LinearWinForm
Linear barcode = new Linear();

// ISBN Barcode Basic Settings
barcode.Type = BarcodeType.ISBN;

/*
ISBN Valid data char set:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9 (Digits)

ISBN Valid data length: 12 digits only, starting with "978" or "979" only
*/
barcode.Data = "978730216365";

// for ISBN with supplement data (2 or 5 digits)
/*
barcode.SupData = "12";
// supplement bar height vs bar height ratio
barcode.SupHeight = 0.8f;
// space between barcode and supplement barcode (in pixel)
barcode.SupSpace = 15;
*/

// Barcode Size Related Settings
barcode.UOM = UnitOfMeasure.PIXEL;
barcode.X = 1;
barcode.Y = 80;
barcode.LeftMargin = 20;
barcode.RightMargin = 20;
barcode.TopMargin = 0;
barcode.BottomMargin = 0;
barcode.Resolution = 96;
barcode.Rotate = Rotate.Rotate0;

// Barcode Text Settings
barcode.ShowText = true;
barcode.TextFont = new Font("Arial", 9f, FontStyle.Regular);
barcode.TextMargin = 6;

// Image format setting
barcode.Format = ImageFormat.Gif;

barcode.drawBarcode(@"c:\isbn.gif");
 
Back
Top Bottom