C# GS1-128 Generator Library
How to generate GS1-128(UCC/EAN-128) barcode in .NET ASP.NET, Windows application


Generate GS1-128 & Insert Barcode into Images and Documents in C#.NET





C# Imaging - GS1-128 Generating Overview



GS1-128 (UCC/EAN-128), owing to its unique feature for carrying information of encoded data, is widely used in international trade field. Therefore, a mature GS1-128 (UCC/EAN-128) barcode generating SDK will bring great benefits to your business. To help C#.NET developers have a better grasp of how GS1-128 (UCC/EAN-128) barcode is generated on images and documents using C#.NET code, we provide this online tutorial for users.



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


RasterEdge GS1-128 (UCC/EAN-128) barcode creator SDK is a professional third-party barcode generating toolkit for .NET. This C#.NET linear barcode creator SDK combines advanced & high-quality GS1-128 (UCC/EAN-128) barcode generating features with mature document imaging technologies. Thus, using this GS1-128 (UCC/EAN-128) barcode generating component, C#.NET developers can easily generate and insert created linear barcode into target documents and images.


As is said above, RasterEdge C#.NET GS1-128 (UCC/EAN-128) barcode generator add-on is a fully-featured .NET solution. And the key features of this barcode creator control are listed below.


Created GS1-128 (UCC/EAN-128) barcodes are compatible with latest industry standards


Able to create & insert GS1-128 (UCC/EAN-128) barcode into both images and documents using C# code


Support generating and adding other linear and 2d barcodes to document & image files, like QR Code and Code 128


Created GS1-128 (UCC/EAN-128) barcode can be flexibly repositioned on target documents or images using C#


Supported document and image files are JPEG, BMP, GIF, PNG, TIFF, PowerPoint, PDF, Excel and Word




C# Code for Customizing GS1-128 Barcode Generation



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




private static Linear CreateBarcode()
        {
            Linear barcode = new Linear();// create a barcode
            barcode.Type = BarcodeType.EAN128;// select barcode type
            barcode.Data = "(01)123456789";// 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 GS1-128 Linear Barcode on Image in C#.NET



In daily-life applications, you may need to draw or add GS1-128 (UCC/EAN-128) barcode on some image files for certain purpose. Then this C#.NET GS1-128 (UCC/EAN-128) barcode generator add-on will be a great choice. Using the APIs that RasterEdge .NET GS1-128 (UCC/EAN-128) barcode creator add-on offers, C# developers can accurately draw a standard GS1-128 barcode on target image files (supported image formats are JPEG, BMP, GIF and PNG).


In the following example, we will take GS1-128 barcode generation on a PNG image file as a case to illustrate.




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





Create GS1-128 on Document in C#.NET



Currently, GS1-128 (UCC/EAN-128) barcode generator add-on for .NET, C#.NET has been widely used in document management and file tracking field. Different from other GS1-128 (UCC/EAN-128) barcode creator SDKs on the market, RasterEdge C#.NET barcode creator add-on allows developers to select one page from source document file (supported document files are PDF, Word, TIFF, Excel and PPTX) and insert a GS1-128 (UCC/EAN-128) barcode into selected document page with accurate location.



Sample C# Code to Create GS1-128 on PDF



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




Sample C# Code to Add GS1-128 to TIFF



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




Sample C# Code to Insert GS1-128 into Word



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




Demo Code to Create GS1-128 Barcode on Excel



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 Add GS1-128 to PPTX 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");
        }





Sample C# Code to Customize GS1-128 Generation



With the following C# programming code, you can easily draw a fully-customized GS1-128 (UCC/EAN-128) barcode on target PNG image file in C#.NET application.




// 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.EAN128;// select barcode type
barcode.Data = "(01)123456789";// set barcode data 

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

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

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

// EAN-128 special
barcode.ProcessTilde = false;

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

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