C# Code 2 of 5 Generator Library
C# Imaging - C# Code 2 of 5 Generator
Create Code 2 of 5 Barcode in C#.NET Project Images and Documents
C# Imaging - Code 2 of 5 Barcode Generator Overview
Code 2 of 5 Barcode Creator Add-on of RasterEdge DocImage SDK for .NET is a fully-functional barcode generating control DLL. It can be easily integrated into C#.NET imaging projects such as C# class library, ASP.NET web projects and windows applications. To use this library, the minimum requirement is the installation of MS Visual Studio 2005 or later.
Related .net document control helps:
asp.net document viewer control:
EdgeDoc:ASP.NET Document Viewer C# Control:
Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
asp.net edit pdf page:
ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
asp.net dicom viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
asp.net tiff viewer control: ASP.NET Tiff Viewer: view, annotate multipage Tiff images in ASP.NET MVC, WebForms using C# Control
asp.net open word document in browser: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
asp.net image viewer zoom: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery
mvc document viewer: ASP.NET MVC Document Viewer: view, annotate, redact files on ASP.NET MVC web projects
Detailed features are listed below:
Written in managed C# code for .NET Framework
Generate, print Code 2 of 5 linear bar codes with complete C# sample codes
Adjust Code 2 of 5 barcode size with parameters listed in the table below
Printing, writing Code 2 of 5 barcodes on jpg, gif, png, and bmp images using C#
Draw and embed high-quality Code 2 of 5 on PDF, TIFF, Microsoft Word, Excel and PowerPoint documents
Besides this C# barcode generation guide, we also provide developers with VB.NET Code 2 of 5 Barcode Drawing Tutorial.
C# Code for Customizing Code 2 of 5 Barcode Generation
You can easily generator Code 2 of 5 barcode and save it to image files/object using this C#.NET barcode generator control. The following steps will show how to create a Code 2 of 5 type barcode encoding numeric data text "112233445566" into the image object with XImage.Barcode.Creator.
Add References
RasterEdge.Imaging.Basic.dll
RasterEdge.Imaging.Drawing.dll
RasterEdge.Imaging.Font.dll
RasterEdge.Imaging.Processing.dll
RasterEdge.XImage.BarcodeCreator.dll
System.Drawing.dll
Using Namespaces
using System.Drawing;
using RasterEdge.XImage.BarcodeCreator;
Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:
If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.
If using x86, the platform target should be x86.
Please copy the sample code as follow to generator a Code 2 of 5 barcode.
private static Linear CreateBarcode()
{
Linear barcode = new Linear();// create a barcode
barcode.Type = BarcodeType.CODA2OF5;// select barcode type
barcode.Data = "112233445566";// set barcode data
barcode.X = 1.0F;// set x
barcode.Y = 60.0F;// set y
barcode.Resolution = 96;// set resolution
barcode.Rotate = Rotate.Rotate0;// set rotation
barcode.BarcodeWidth = 200;
barcode.BarcodeHeight = 200;
barcode.AutoResize = true;
//convert barcode to a bitmap and save it to image file
//Bitmap bmp = barcode.ToImage();
//bmp.Save(@"C:\barcode.bmp");
return barcode;
}
|

|
|
C# Imaging - Create Code 2 of 5 Barcode on Image
This C#.NET library add-in is designed to help developers create, draw Code 2 of 5 bar codes on various image files. Supported image formats include png, gif, jpeg, and bmp. The sample code below is taking the png image format for Code 25 generation as an example. Copy and paste it to your C#.NET image program for a test and make necessary adjustment on the C# code to create custom Code 2 of 5 image. You can view detailed settings in the property table below.
private static void AddBarcodeToImage(Linear barcode)
{
REImage image = new REImage(inputDirectory + "Sample.png");
barcode.DrawBarcode(image, 150F, 150F);
image.Save(ImageType.PNG, outputDirectory + "Sample_Barcode.png");
}
|
C# Imaging - Insert Code 2 of 5 Barcode on Document
Apart from the image processing project, this C#.NET barcode generator add-on can be also used in those document managing & manipulating projects. Using this .NET Code 2 of 5 barcode creator add-on, you can easily generate & insert Code 2 of 5 barcode on PDF, TIFF, Word, Excel and PowerPoint documents.
Code 2 of 5 Barcode Generation on PDF Page
Add References(Extra)
RasterEdge.Imaging.Basic.Codec.dll
RasterEdge.XImage.Raster.dll
RasterEdge.XImage.Raster.Core.dll
RasterEdge.XDoc.PDF.dll
Using Namespace(Extra)
RasterEdge.XDoc.PDF;
RasterEdge.Imaging.Basic;
RasterEdge.Imaging.Raster.Core;
private static void AddBarcodeToPDF(Linear barcode)
{
PDFDocument docx = new PDFDocument(inputDirectory + "Sample.pdf");
BasePage page = docx.GetPage(0);
REImage image = new REImage(barcode.ToImage());
page.AddImage(image, new PointF(100F, 100F));
docx.Save(outputDirectory + "Sample_Barcode.pdf");
}
|
Code 2 of 5 Barcode Generation on TIFF Page
Add References(Extra)
RasterEdge.Imaging.Basic.Codec.dll
RasterEdge.XImage.Raster.dll
RasterEdge.XImage.Raster.Core.dll
RasterEdge.XDoc.TIFF.dll
Using Namespace(Extra)
RasterEdge.XDoc.TIFF;
RasterEdge.Imaging.Basic;
RasterEdge.Imaging.Raster.Core;
private static void AddBarcodeToTIFF(Linear barcode)
{
TIFFDocument docx = new TIFFDocument(inputDirectory + "Sample.tif");
BasePage page = docx.GetPage(0);
REImage image = new REImage(barcode.ToImage());
page.AddImage(image, new PointF(100F, 100F));
docx.Save(outputDirectory + "Sample_Barcode.tif");
}
|
Code 2 of 5 Barcode Generation on Word Page
Add References(Extra)
RasterEdge.XDoc.Word.dll
RasterEdge.XImage.Raster.dll
RasterEdge.XImage.Raster.Core.dll
RasterEdge.XDoc.Office.Inner.Common.dll
RasterEdge.XDoc.Office.Inner..Office03.dll
Using Namespace(Extra)
RasterEdge.XDoc.Word;
RasterEdge.Imaging.Basic;
RasterEdge.Imaging.Raster.Core;
private static void AddBarcodeToWord(Linear barcode)
{
DOCXDocument docx = new DOCXDocument(inputDirectory + "Sample.docx");
BasePage page = docx.GetPage(0);
REImage image = new REImage(barcode.ToImage());
page.AddImage(image, new PointF(100F, 100F));
docx.Save(outputDirectory + "Sample_Barcode.docx");
}
|
Create and Save Code 2 of 5 on Excel Document
Add References(Extra)
RasterEdge.XDoc.Excel.dll
RasterEdge.XImage.Raster.dll
RasterEdge.XImage.Raster.Core.dll
RasterEdge.XDoc.Office.Inner.Common.dll
RasterEdge.XDoc.Office.Inner..Office03.dll
Using Namespace(Extra)
RasterEdge.XDoc.Excel;
RasterEdge.Imaging.Basic;
RasterEdge.Imaging.Raster.Core;
private static void AddBarcodeToExcel(Linear barcode)
{
XLSXDocument docx = new XLSXDocument(inputDirectory + "Sample.xlsx");
BasePage page = docx.GetPage(0);
REImage image = new REImage(barcode.ToImage());
page.AddImage(image, new PointF(100F, 100F));
docx.Save(outputDirectory + "Sample_Barcode.xlsx");
}
|
C# Code to Draw Code 2 of 5 Barcode to PowerPoint Page
Add References(Extra)
RasterEdge.XDoc.PowerPoint.dll
RasterEdge.XImage.Raster.dll
RasterEdge.XImage.Raster.Core.dll
RasterEdge.XDoc.Office.Inner.Common.dll
RasterEdge.XDoc.Office.Inner..Office03.dll
Using Namespace(Extra)
RasterEdge.XDoc.PowerPoint;
RasterEdge.Imaging.Basic;
RasterEdge.Imaging.Raster.Core;
private static void AddBarcodeToPowerPoint(Linear barcode)
{
PPTXDocument docx = new PPTXDocument(inputDirectory + "Sample.pptx");
BasePage page = docx.GetPage(0);
REImage image = new REImage(barcode.ToImage());
page.AddImage(image, new PointF(100F, 100F));
docx.Save(outputDirectory + "Sample_Barcode.pptx");
}
|
C# Sample Code for Code 2 of 5 Customization
From the following C# code, you will see how to generate a customized Code 2 of 5 barcode on a png image file in .NET class application. All the properties listed above are demonstrated, please make any modification if necessary.
// create REImage on which you want to draw the barcode
REImage reImage = new REImage("c:/Sample.png");
Linear barcode = new Linear();// create a barcode
barcode.Type = BarcodeType.CODE2OF5;// select barcode type
barcode.Data = "0123456789";// set barcode data
// Code 2 of 5 size settings
barcode.UOM = RasterEdge.Imaging.Barcode.Creator.UnitOfMeasure.PIXEL;
barcode.X = 2.0F;
barcode.Y = 80F;
barcode.BarcodeHeight = 120;
barcode.BarcodeWidth = 120;
barcode.BottomMargin = 20;
barcode.TopMargin = 20;
barcode.BottomMargin = 20;
barcode.LeftMargin = 20;
barcode.RightMargin = 20;
barcode.AutoResize = false;
barcode.BarAlignment = AlignmentHori.Center;
// Code 2 of 5 unique features
barcode.N = 2;
// color-related settings
barcode.BackColor = System.Drawing.Color.White;
barcode.ForeColor = System.Drawing.Color.Black;
// human-readable text-related settings
barcode.ShowText = true;
barcode.TextFont = new Font("Arial", 9f, FontStyle.Regular);
barcode.TextMargin = 6F;
barcode.TextColor = System.Drawing.Color.Black;
// other related settings
barcode.Resolution = 96;
barcode.Rotate = Rotate.Rotate0;
barcode.DrawBarcode(reImage, 0, 0);// draw barcode on REImage with location x and y
reImage.Save(ImageType.PNG, @"c:/barcode.png");
|