C#: Online Guide
How To: Barcode Generator
Interleaved 2 of 5
Interleaved 2 of 5
  |  
Home ›› XImage.Barcode Generator ›› C# Barcode Generator: Interleaved 2 of 5

C# Imaging - Interleaved 2 of 5 Generator Tutorial


Interleaved 2 of 5 Creation on Image and Document Using C#.NET Code




C# Imaging - Interleaved 2 of 5 Creating Overview



RasterEdge Interleaved 2 of 5 C# barcode creator add-on offers easy-to-use and mature APIs for C# developers to generate a customized Interleaved 2 of 5 barcode and draw created barcode on both raster image files and common documents in .NET developing platforms, without using other external barcode related third-party software.


Related .net document control helps:
asp.net image file viewer: ASP.NET Image Document Viewer Control: view, annotate, redact, convert image files in html web browser
asp.net edit pdf page control: ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
asp.net edit pdf text control: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net edit pdf image control: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net annotate pdf control: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
asp.net mvc pdf editor control: ASP.NET MVC PDF Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
asp.net sharepoint pdf editor control: ASP.NET SharePoint PDF Editor Control: view, edit, annotate, redact PDF document in SharePoint sites


Compared to other C#.NET Interleaved 2 of 5 barcode generating SDKs on the market, this C#.NET Barcode Creator Add-on successfully stands itself out based on its outstanding Interleaved 2 of 5 barcode generating features.


Written in 100% managed C# code and can be integrated into both .NET web-based and WinForms applications


Created Interleaved 2 of 5 barcode are compatible with latest ISO/IEC specifications and industry standards


Generated Interleaved 2 of 5 can be accurately inserted into BMP, GIF, JPEG & PNG image files using C# code


Created Interleaved 2 of 5 barcode can be also added to PDF, Excel, PowerPoint, Word and TIFF document files


Free to generate & draw other 26 1d & 2d barcodes on documents & images using C#.NET programming code




C# Code for Customizing Interleaved 2 of 5 Barcode Generation



You can easily generator Interleaved 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 Interleaved 2 of 5 type barcode encoding numeric data text "01234567890123456789" 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 Interleaved 2 of 5 barcode.




private static Linear CreateBarcode()
        {
            Linear barcode = new Linear();// create a barcode
            barcode.Type = BarcodeType.INTERLEAVED25;// 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;
        }





Draw Interleaved 2 of 5 Barcode on Image in C#



In this section, we will give you a C# programming example on how to create Interleaved 2 of 5 barcode and insert created barcode on target image file. Supported image file formats are PNG, JPEG, GIF and BMP. Using this C#.NET Interleaved 2 of 5 barcode creator add-on, you can insert created barcode into specified area of your loaded image file.




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");
        }





Draw Interleaved 2 of 5 on Document Page in C#



Using RasterEdge C# Interleaved 2 of 5 barcode creator SDK, you can also create and add standard Interleaved 2 of 5 barcode to document page using C#.NET programming. Supported document types are Word, Excel, PowerPoint, PDF and TIFF.



C# Interleaved 2 of 5 Creation on PDF Document



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");
        }




C# Interleaved 2 of 5 Creation on TIFF File 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");
        }




C# Interleaved 2 of 5 Creation on Word Document



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");
        }




C# Interleaved 2 of 5 Barcoding on Excel Sheet



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# Interleaved 2 of 5 Barcode Writing on PowerPoint



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# Demo Code for Interleaved 2 of 5 Customization



The following C# code demo contains all the APIs that you can use to create and customize Interleaved 2 of 5 barcode on documents and image files in .NET applications.




// 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.INTERLEAVED25;// select barcode type
barcode.Data = "112233445566";// set barcode data 

// Interleaved 2 of 5 barcode size related
barcode.X = 1.0F;// set x
barcode.Y = 60.0F;// set y
barcode.BarcodeHeight = 60;
barcode.BarcodeWidth = 0;
barcode.BottomMargin = 0;
barcode.LeftMargin = 0;
barcode.RightMargin = 0;
barcode.BarAlignment = AlignmentHori.Center;
barcode.Resolution = 72;// set resolution
barcode.Rotate = Rotate.Rotate0;// set rotation
barcode.AddCheckSum = false;
barcode.UOM = RasterEdge.Imaging.Barcode.Creator.UnitOfMeasure.PIXEL;

// Interleaved 2 of 5 colors
barcode.BackColor = System.Drawing.Color.White;
barcode.ForeColor = System.Drawing.Color.Black;

// Interleaved 2 of 5 font style
barcode.TextFont = new Font("Arial", 9f, FontStyle.Regular);
barcode.TextColor = System.Drawing.Color.Black;
barcode.TextMargin = 6;
barcode.ShowText = true;

// Interleaved 2 of 5 special
barcode.N = 2.0f;

barcode.DrawBarcode(reImage, 0, 0);// draw barcode on REImage with location x and y

reImage.Save(ImageType.PNG, @"c:/barcode.png");