C# EAN-13 Generator Library
C# Imaging - EAN-13 Creation & Printing


Generate & Insert EAN-13 Barcode into Document and Image Files Using C#





C# EAN-13 Barcode Creator Overview



RasterEdge .NET EAN-13 barcode generation add-on is a fully functional utility, which offers advanced and mature API for C# developers to create high-quality EAN-13 barcode and add generated EAN-13 barcode to target document or image file in both .NET web-based application and Windows Forms project.



Related .net document control helps:
document viewer asp.net c#: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
asp.net view text file: ASP.NET Text file viewer in MVC, WebForms: Open, view, annotate, convert txt files in C# ASP.NET
asp.net office document viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
asp.net pdf editor component: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
asp.net annotate pdf control: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
asp.net image viewer jquery: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery
powerpoint viewer asp.net mvc: ASP.NET PowerPoint Document Viewer Control (MVC & WebForms): view ppt, pptx files online in C# using ASP.NET


Here we offer a brief feature list of RasterEdge C#.NET linear EAN-13 barcode generator add-on.


100% .NET solution that allows developers to generate EAN-13 barcode in C# imaging applications


Generate and add created EAN-13 barcode on image file formats (JPEG, JBIG2, BMP, GIF & PNG) using C# code


Created linear EAN-13 barcode can be easily and accurately inserted into PDF, TIFF, Word, Excel and PowerPoint document files using C#.NET


Created EAN-13 barcodes meeting latest industry standards and can be read by all linear barcode readers in C#


Fully-featured EAN-13 barcode generating API that helps C# developers create customized barcode




C# Code for Customizing EAN-13 Barcode Generation



You can easily generator EAN-13 barcode and save it  to image files/object using this C#.NET barcode generator control. The following steps will show how to create a EAN-13 type barcode encoding numeric data text "012345678901" 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 EAN-13 barcode.




private static Linear CreateBarcode()
        {
            Linear barcode = new Linear();// create a barcode
            barcode.Type = BarcodeType.EAN13;// select barcode type
            barcode.Data = "012345678901";// 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;
        }





Generate EAN-13 Barcode on Image in C#



In this section, we will offer you a C# programming example which aims to demonstrate how to generate a standard EAN-13 barcode on raster image file PNG. Using RasterEdge .NET EAN-13 barcode creator add-on, you can also generate EAN-13 barcode on other image file formats, like JPEG, BMP and GIF.




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





Generate EAN-13 on Document Page in C#



Besides generating EAN-13 barcode on image files, RasterEdge C#.NET EAN-13 barcode creator can also generate & add EAN-13 barcode on document files, like PDF, TIFF, Word, Excel and PowerPoint. Using the sample C# codes below, you can not only insert EAN-13 barcode on target document page, but also own the ability to adjust the position where created EAN-13 barcode will be located.



EAN-13 Creation on PDF Document in C#



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




EAN-13 Creation on TIFF File Page Using C#



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# EAN-13 Creation on Word Document Using C#



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# EAN-13 Creation on Excel Document Using C#



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# EAN-13 Creation on PowerPoint Document Using C#



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# Code to Generate Customized EAN-13 on Document Image



The C# code demo below contains all parameters that C# developers can use to create a customized EAN-13 barcode on target image file. For example, you can adjust the size, color, font style and generating orientation of created EAN-13 barcode by C# code.




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

// EAN-13 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.Left;
barcode.Resolution = 96;// set resolution
barcode.Rotate = Rotate.Rotate0;// set rotation
barcode.AddCheckSum = false;
barcode.UOM = RasterEdge.Imaging.Barcode.Creator.UnitOfMeasure.PIXEL;

// EAN-13 colors
barcode.BackColor = System.Drawing.Color.White;
barcode.ForeColor = System.Drawing.Color.Black;

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

// EAN-13 special
// barcode.SupData = "";
// barcode.SupHeight = 0.8f;
// barcode.SupSpace = 15;

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

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