Guide for C#
Core Document Formats
Additional Features
UPC-A

C# Imaging - UPC-A Barcode Generator

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

Visual C#
Home > .NET Imaging SDK > C# > Generate UPC-A Barcode
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

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.
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
This online tutorial page for C#.NET UPC-A barcode creation on images and documents are divided into following five sections.
  • How to add UPC-A barcode to raster image files using sample C# code
  • How to draw UPC-A barcode on PDF, Word, TIFF, Excel and PowerPoint documents in C#
  • Complete C# UPC-A barcoding parameters
  • Demo C# code for customizing UPC-A barcode creation on document image files
  • C# UPC-A barcode creator control FAQ
If needed, please try this C#.NET UPC-A barcode reader add-on to integrate UPC-A barcode detecting and reading functions into your C#.NET project. If you want to integrate UPC-A barcode generating features into VB.NET class application, please read this tutorial page for VB.NET UPC-A barcode generation guide.
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.
// invoke this only once at the beginning of your code
WorkRegistry.Reset();

// 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
barcode.X = 1.0F;// set x
barcode.Y = 60.0F;// set y
barcode.Resolution = 96;// set resolution
barcode.Rotate = Rotate.Rotate0;// set rotation

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

reImage.Save(ImageType.PNG, @"c:/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#

PDFDocument doc = new PDFDocument("c:/Sample.pdf");
PDFPage page = (PDFPage)doc.GetPage(0);

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

// add this barcode image to this page
REImage barcodeImage = barcode.ToImage();
page.AddImage(barcodeImage, new System.Drawing.PointF(100f, 100f));

// save the changes
doc.Save(@"c:/barcode.pdf");

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

// load TIFF document. You can also load document like PDF, Word, Excel & PPT
TIFFDocument tiff = new TIFFDocument(@"c:\sample.tiff");

// get the first page
BasePage page = tiff.GetPage(0);

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

// add barcode image to the first page
REImage barcodeImage = barcode.ToImage();
page.AddImage(barcodeImage, new System.Drawing.PointF(100f, 100f));

// save changes to TIFF document
tiff.Save(@"c:\barcode.tiff");

How to Add UPC-A to Word Document in C#

// construct an DOCXDocument
DOCXDocument doc = new DOCXDocument(@"c:/Sample.docx");

// get the first page
BasePage page = doc.GetPage(0);

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

// add barcode image to the first page
REImage barcodeImage = barcode.ToImage();
page.AddImage(barcodeImage, new System.Drawing.PointF(100f, 100f));

// save changes to the file
doc.Save(@"c:\barcode.docx");

How to Draw UPC-A on Excel Document in C#

// construct an XLSXDocument
XLSXDocument doc = new XLSXDocument(@"c:/Sample.xlsx");

// get the first page
BasePage page = doc.GetPage(0);

Linear barcode = new Linear();// create a barcode
barcode.Type = BarcodeType.UPCA;// select barcode type
barcode.Data = "01234567890";// set barcode data
barcode.X = 3.0F;
barcode.Resolution = 90;
barcode.Rotate = Rotate.Rotate90;

// add barcode image to the first page
REImage barcodeImage = barcode.ToImage();
page.AddImage(barcodeImage, new System.Drawing.PointF(100f, 100f));

// save changes to the file
doc.Save(@"c:\barcode.xlsx");

How to Create UPC-A Barcode to PPT Slide

// construct an PPTXDocument
PPTXDocument doc = new PPTXDocument(@"c:/Sample.pptx");

// get the first page
BasePage page = doc.GetPage(0);

Linear barcode = new Linear();// create a barcode
barcode.Type = BarcodeType.UPCA;// select barcode type
barcode.Data = "01234567890";// set barcode data
barcode.X = 4.0F;
barcode.Resolution = 72;

// add barcode image to the first page
REImage barcodeImage = barcode.ToImage();
page.AddImage(barcodeImage, new System.Drawing.PointF(100f, 100f));

// save changes to the file
doc.Save(@"c:\barcode.pptx");
UPC-A Barcoding Parameters and C# Code Demo
Sometimes, C# developers are required to create document file with linear UPC-A barcode that has certain fixed margins, text font style or specific generation orientation. Therefore, a professional UPC-A barcode creator add-on, which allows C# developers to create highly-readable UPC-A barcode on document file and also helps them adjust generated UPC-A barcode properties to their desired values, is quite necessary.
Here we present all barcoding parameters, supported by Visual C# UPC-A barcode creator add-on, in the following chart.
UPC-A SETTING+
UPC-A SETTING-
Type UPCA, UPCA_2, UPCA_5
Data Format
UOM(Unit of Measure)
Rotate
BarAlignment Resolution(DPI)
AutoResize AddCheckSum
X(Bar Width) ShowText
Y(Bar Height) TextFontSize
BarcodeWidth TextMargin
BarcodeHeight TextFont
LeftMargin TextColor
RightMargin TextFontStyle
TopMargin BackColor
BottomMargin ForeColor
SupData SupHeight
SupSpace

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.
// invoke this only once at the beginning of your code
WorkRegistry.Reset();

// 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");
C# UPC-A Barcode Generator Library FAQ
Can I create and insert multiple UPC-A barcodes on source document image file at a time using the APIs that RasterEdge C#.NET UPC-A Barcode Creator Add-on offers?
Sorry, using RasterEdge C#.NET UPC-A barcode generation API, developers can only create & insert one UPC-A barcode into target document or image file at a time.


Recommend this to Google+