Tech Specs
How-to C#
How-to VB.NET
C# PDF: How to HTML5 Viewer & Editor PDF Create PDF Export File and Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF Viewer & Editor Work with Other SDKs Barcode Read Barcode Create OCR Twain
Barcode Create
Home ›› XDoc.PDF ›› C# PDF: Create Barcode

C#.NET PDF - Create Barcode on PDF in C#.NET

C# Sample Codes for Creating 1D & 2D Barcodes on PDF Page in C#.NET Imaging Program

C# PDF Barcode Creation Overview

RasterEdge C#.NET PDF Barcode Creation SDK offers mature APIs for developers to generate, write and create 1d and 2d barcodes on PDF document page using C#.NET code. Besides, using this C#.NET barcode creator control package, you can easily adjust and customize most attribute properties of generated barcodes on PDF document file, like color, size and positional parameters.

Details about C# PDF Document Barcode Creation features:

100% C#.NET PDF barcode creating solution compacted in small-sized dlls

Mature C# PDF barcode generation controls available for both ASP.NET Web and WinForms programs

Compatible with Microsoft .NET Framework from version 2.0 to 4.5

Generate over 20 linear and 2d barcodes on PDF document page using C#.NET

Create 1d & 2d barcodes on accurate location of PDF document page using C# code for .NET

Able to use C#.NET class code to customize created PDF barcode image properties

How to Create Barcode on PDF Page in C#.NET

Add necessary references:










Use corresponding namespaces;

  using RasterEdge.Imaging.Basic;

  using RasterEdge.XDoc.PDF;

  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.

This is a simple C# example for PDF barcode creation.

// generate a Code 39 barcode
Linear linearBarcode = new Linear();
linearBarcode.Type = BarcodeType.CODE39;
linearBarcode.Data = "123456789";
linearBarcode.Resolution = 96;
linearBarcode.Rotate = Rotate.Rotate0;

// load PDF document, you can also load document like TIFF, Word, Excel & PPT
PDFDocument doc = new PDFDocument(@"c:\sample.pdf");

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

// generate reimage of this barcode
Bitmap barcodeImage = linearBarcode.ToImage();

// add barcode image to the first page and the top left vertex of barcode image rectangle is at point(100,100)
page.AddImage(barcodeImage, new System.Drawing.PointF(100f, 100f));

// save changes to the PDF
doc.Save(@"c:\output.pdf ");