C# Barcode Generator Library
UPC-A Barcode Generator


How to Add and Insert UPC-A Barcode to Image & Document in C#





C# Imaging - UPC-A Barcode Add-on Overview



Our .NET UPC-A barcode creator add-on is designed to help C# developers create standard linear UPC-A barcode and add generated UPC-A barcode to documents and image files in .NET applications.



Related .net document control helps:
asp.net sharepoint document viewer free: ASP.NET SharePoint Document Viewer: view, annotate, redact documents in SharePoint
asp.net pdf editor component: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents
asp.net mvc pdf editor control: ASP.NET MVC PDF Viewer & Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
asp.net view excel in browser: ASP.NET Excel Viewer in C# Control (MVC & WebForms): view Office Excel document in web browser.
powerpoint viewer asp.net mvc: ASP.NET PowerPoint Document Viewer Control (MVC & WebForms): view ppt, pptx files online in C# using ASP.NET
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 document viewer free: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...


Following is a feature list of RasterEdge C#.NET UPC-A barcode creator add-on.


Mature UPC-A barcode generator SDK for C#.NET document and image processing applications


Insert linear UPC-A barcode into images and documents using Visual C# programming language


Created UPC-A barcode can be processed separately on target document or image file using C#.NET


Offer complete parameters for C# developers to create UPC-A barcode with desired property values




C# Code for Customizing UPC-A Barcode Generation



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




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





How to Add UPC-A Barcode to Image in C#



In this section, you can find sample C# code, which is used to illustrate how to create and draw UPC-A barcode on source image, picture or photo in .NET class application. Now, our Barcode Generator DLL for C#.NET supports creating UPC-A barcode on BMP, GIF, JPEG, and PNG image files. Remarkably, developers can draw linear UPC-A barcode at any desired place on source image file as this C# UPC-A Barcode Generator DLL provides the application of X & Y location.




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





How to Create UPC-A on Document Page in C#



This C# UPC-A barcode generator SDK is often used by developers for the purpose of adding linear UPC-A barcode to document files, like PDF, TIFF, MS Word, Excel and PowerPoint. What should be noted here is that, using RasterEdge UPC-A barcode creator SDK, you can create and insert UPC-A barcode at any specified location of any page on target document files accurately by C# programming code.



How to Insert UPC-A Barcode into PDF Using 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");
        }




How to Draw UPC-A on TIFF Using C#.NET



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




How to Add UPC-A to Word Document in 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");
        }




How to Draw UPC-A on Excel Document in 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 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");
        }




How to Create UPC-A Barcode to PPT Slide



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





Entire C# Code for Customizing UPC-A Barcode



As is said above, RasterEdge UPC-A barcode creator add-on for C# owns comprehensive barcode generating functions, which allows C# developers to create a fully-customized UPC-A barcode and insert generated UPC-A barcode into source document image file. In this section, we particularly illustrate C# code demo for developers, which can be used to create UPC-A barcode and customize each property of generated barcode image on sample PNG image file.




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

// UPC-A 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;

// UPC-A colors
barcode.BackColor = System.Drawing.Color.White;
barcode.ForeColor = System.Drawing.Color.Black;

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

// UPC-A special
// barcode.SupData = "";
// barcode.SupHeight = 0.8f;
// barcode.SupSpace = 15f;

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

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