C# Code 39 Generator Library
C# Code 39 Barcoding Tutorial
Draw Code 39 Barcode on Raster Images, TIFF, PDF, Word, Excel and PowerPoint
C# Imaging Code 39 Barcode Add-on Overview
RasterEdge DocImage SDK for .NET includes this RasterEdge.Imaging.Barcode.Creator.dll for C# developers to generate and create Code 39 on
TIFF, PDF, Word, Excel and PowerPoint documents and raster image files using C# class codes.
With the sample codes demonstrated below, users can freely create and print Code 39 bar codes on any page within TIFF, PDF, Excel, PowerPoint or Word file,
and at any location on a Jpeg, Gif, Png, or Bmp image. And below are the main features.
Related .net document control helps:
asp.net document viewer control:
EdgeDoc:ASP.NET Document Viewer C# Control:
Open, view, annotate, redact, convert documents online in C#, VB.NET, AS...
asp.net edit pdf page:
ASP.NET PDF Pages Edit Control: add, remove, sort, replace PDF pages online using C#
asp.net dicom viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET
asp.net tiff viewer control: ASP.NET Tiff Viewer: view, annotate multipage Tiff images in ASP.NET MVC, WebForms using C# Control
asp.net open word document in browser: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
asp.net edit pdf image control:
ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net edit pdf text color:
ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
Create Code 39, Code 39 Extension encoding alphanumeric data in .NET
C# Code 39 component DLL designed for Visual Studio 2005 or above
Resize Code 39 linear bar code image by controlling barcode width & barcode height
Include algorithm to automatically add Code 39 check digit character / checksum
Adjust Code 39 image resolution for high-quality output suitable for all printers
C# Code for Customizing Code 39 Barcode Generation
You can easily generator Code39 barcode and save it to image files/object using this C#.NET barcode generator control. The following steps will show how to create a Code39 type barcode encoding numeric data text "0123456ABCD" 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 Code39 barcode.
private static Linear CreateBarcode()
{
Linear barcode = new Linear();// create a barcode
barcode.Type = BarcodeType.CODE39;// select barcode type
barcode.Data = "0123456ABCD";// 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 Code 39 on Raster Image in C# Project
With the following Visual C# demo code, you are able to generate Code 39 on raster image files, including BMP, PNG, GIF, and JPEG formats. Below are some basic settings for Code 39. For more dimension settings, please refer to the complete property table below. You will be able to adjust barcode location on image, and control Code 39 size, resolution, checksum, orientation, color, and text, etc.
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");
}
|
Generate Code 39 on Certain Document Page
This section will demonstrate how to generate & embed Code 39 on PDF, multi-page TIFF, Microsoft Office Word document (.docx), Excel sheet (.xlsx) and PowerPoint (.pptx). Visual C# users can draw it at any location of document page, and adjust Code 39 parameters freely.
Write C# Code 39 on Defined Area in PDF Document
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");
}
|
Create C# Code 39 on Multi-page TIFF Document
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");
}
|
Draw C# Code 39 on Office Word Document
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");
}
|
Write C# Code 39 Image on Excel Sheet
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");
}
|
Create C# Code 39 Barcode on PowerPoint 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");
}
|
Generate Code 39 with C# Code
RasterEdge offers free and accurate C# example code to create customized Code 39 on image and document files, by adjusting the properties listed above.
// 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.CODE39;// select barcode type
barcode.Data = "0123456ABCD";// set barcode data
// Code 39 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;
// Code 39 colors
barcode.BackColor = System.Drawing.Color.White;
barcode.ForeColor = System.Drawing.Color.Black;
// Code 39 font style
barcode.TextFont = new Font("Arial", 9f, FontStyle.Regular);
barcode.TextColor = System.Drawing.Color.Black;
barcode.TextMargin = 6;
barcode.ShowText = true;
// Code 39 special
barcode.I = 1.0f;
barcode.N = 2.0f;
barcode.ShowStartStopInText = true;
barcode.ProcessTilde = false;
barcode.DrawBarcode(reImage, 0, 0);// draw barcode on REImage with location x and y
reImage.Save(ImageType.PNG, @"c:/barcode.png");
|
Create and customize Code 39 barcode in C# ASP.NET, WinForms apps
Using OnBarcode C# Barcode Generator library, you can apply the following two properties to customize the Code 39 bar and space width in C# application.
N: Wide bar width vs narrow bar width ratio, 2.0 - 3.0 inclusive, default is 2.
I: The space between 2 characters in code 39. This is a multiple of X (narrow bar width).
Here we will show how to customize the Code 39 barcode image below through properties
N and
I.
Code 39 Wide bar size vs Narrow bar size ratio (N)
You can apply the Code 39
wide bar vs narrow bar ratio through property
N using C# Code 39 barcode generator library.
The property
N valid value is from
2 to
3 (both inclusive). The default is 2.
Code 39 Intercharacter space (I)
You can apply the Code 39 inter characters space size through property
I in C# class.
The property
I is the space between 2 character bar modules, and it is a multiple of X (narrow bar module width). The default value is
1.0f.
Common Asked Questions
What's the purpose of Code 39 barcodes?
Code 39 barcode also called Code 3 of 9, encodes both letters and numbers. It's widely applied in inventory systems, government operations, military uses, and electronics fields.
Using XImage Code 39 Barcode Generator C# library, you are able to create standard Code 39 barcode and extended Code 39 barcode in ASP.NET Core, MVC, Blazor
and WinForms, WPF web and desktop applications.
How do Code 39 and Code 128 barcodes differ?
The main difference is in error checking. Code 128 needs a checksum. Even if it gets damaged, it might still scan. This makes Code 128 more reliable if the barcode is damaged.
C# Barcode Generator library supports both Code 39 and Code 128 barcodes generation in C# Visual Studio .NET projects.
What's the distinction between Code 39 and Code 93 barcodes?
Code 93 is a more compact barcode format designed to replace Code 39, and it has a higher density. It encodes data in a denser layout, allowing more information in less space.
C# Code 39 barcode generation library supports both Code 39 and Code 93 generation in C# class in ASP.NET web and Windows applications.
Can Code 39 barcodes handle lowercase letters?
Regular Code 39 can't encode lowercase letters; however, you need the Extended Code 39 format.
Code 39 barcode C# generation library supports both regular Code 39 and extended Code 39 barcode generation in ASP.NET Core, web forms, MVC, ASP.NET Framework web applications.
What's the smallest size for Code 39?
Code 39 has these minimum size rules:
Narrow element width (X): the narrow element width (X) is dictated by your scanning equipment.
Barcode height: The barcode's height should meet or exceed 5.0mm or 15% of the symbol width (excluding quiet zones), whichever is greater.
Using XImage.Barcode Generator C# library, you can generate and print Code 39 with bar's size customized in ASP.NET web apps.
What's the ratio between narrow and wide bars in Code 39?
In a Code 39 barcode, the valid ratio of narrow to wide bars ranges must be between 1:2 and 1:3.
Using XImage Code 39 Barcode Generator C# library, you are able to print Code 39 with narrow and wide bars ratio applied in C# ASP.NET and Windows Forms applications.