Drawing and creating high quality EAN-13 barcodes to PDF page.

PDF EAN barcodes are used to label consumer goods worldwide for point of sales scanning, primarily in Europe. They look very similar to UPC codes, and the main distinction is their geographical application. This barcode contains the EAN number or GTIN (Global Trade Item Number) to identify itself. An EAN-13 barcode in PDF document is a standard that uses 13 digits in order to represent a barcode. EAN 8 is a short version of EAN 13 barcode.

C# PDF EAN-13 Creator is one of the generation functions in XsPDF barcode creator for .NET. It allows developers to use CSharp language to make EAN13 graphics and render the barcode in PDF pages.


// Create a new PDF document.
PdfDocument document = new PdfDocument();

// Create a page.
PdfPage page = document.AddPage();

// Get graphics object from pdf page
XGraphics g = XGraphics.FromPdfPage(page);

// Create a pdf barcode object
PdfBarcode barcode = new PdfBarcode();

// Set the barcode type to ean-13 symbol
barcode.BarType = BarCodeType.EAN13;

// Input the barcode data content, only need 12 digital data
// our library will add the check sum automatically
barcode.Data = "123456789012";

// Change foreground and background color of barcode
barcode.BarcodeColor = XColors.Black;
barcode.BackgroundColor = XColors.White;

// Set 1d barcode human-readable text to display
barcode.ShowText = true;
                       
// Set the barcode Position and location
barcode.Location = new XPoint(100, 100);

// Set the barcode width and height
barcode.Size = new XSize(200, 50);

barcode.DrawBarcode(g);

// Save and show the document           
document.Save("Barcode.pdf");
Process.Start("Barcode.pdf");

More PDF tutorial