C# Barcode Generation & Image Settings

How to generate & set barcode image properties in C#.NET Barcode Generator Library

Using C# class code to encode, print and customize barcode images for .NET applicaitons





In this C# tutorial, you will learn how to generate linear and 2d barcodes in multiple image formats, including raster images and vector images in your ASP.NET web app and Windows application.

  • Barcode image with color settings
  • Barcode image with transparent background
  • High resolution barcode image for printing
  • Multiple raster image formats and vector image formats supported

How to create high quality barcode images using C#

  1. Download .NET Barcode Generator Suite
  2. Install C# library to create barcode images in .NET apps
  3. Step by Step Tutorial








  • Quickly installed in Visual Studio C#.NET projects, like C#.NET Windows Forms & ASP.NET web projects
  • Entirely integrate C# barcode generation features into .NET Framework applications
  • Directly generate & print 20+ linear & 2d barcode images in C#.NET class library
  • Free C# barcode download for creating Code 39, Code 128, Interleaved 2 of 5 in Visual C#
  • Able to use C# sample code to save barcodes into multiple raster image file formats, like jpeg, png, gif, bmp, etc
  • Barcode generation for vector images (SVG & EPS) are also supported.
  • Enable users to set and customize generated barcode image color using Visual C#
  • Developer can dynamically adjust barcode image background style, like transparent background
  • Purchase barcode C# source code with developer license
OnBarcode.com .NET Barcode Controls are easy-to-use automation barcoding components (dlls) that have been in use since 2004. All the included components comply with VB.NET, Visual C# .NET. These .NET barcode generation controls support quick creation of linear & bidimensional bar code that can be customized to meet required specifications. The software supports C# barcode ASP.NET, C# barcode graphics design in Win Forms, and C# barcode reporting display.
OnBarcode also provide other examples regarding Visual C# barcode generation, please see below:
  1. Generating Barcode in Visual C# - tutorial for generating batch hgih-quality barcode images in C# program
  2. Creating Barcode in C# ASP.NET - tutorisl for streaming barcodes in ASP.NET web service or html page with C#
  3. Painting Barcode in C# WinForms - tutorial for drawing multiple barcodes images in C# Windows Forms programming
  4. Encoding Barcode in C# Programs - tutorial for creating bulk GS1 barcode or barcodes encoding Unicode using C#

How to Use C# to Set Colorful Barcode Image

Top
Colorful barcode image setting in C# class is very simple. You can set the image functions background color, foreground color, and human readable text color in your C# barcode system. Just follow the quick C# barcode manual below.
Firstly, please downlolad the toolkit and add .NET barcode generator dll into your C# project reference. In the following example, we use OnBarcode.Barcode.WinForms.dll and Code 39 is the sample barcode type with alphanumeric sample string.
   Linear code39 = new Linear();
code39.Type = BarcodeType.CODE39;
code39.Data = "3333999";
code39.X = 1;
code39.Y = 76;
code39.LeftMargin = 10;
code39.RightMargin = 10;

// Customize Code 39 image color
code39.BackColor = Color.Yellow;
code39.ForeColor = Color.Blue;
code39.TextColor = Color.Black;

// Draw Code 39 barcode to C:\
code39.drawBarcode("C://csharp_code39.png");

How to Use C# to Get Transparent Barcode Images

Top
This C#.NET barcode generator suite enables users to create barcode images with transparent background. Currently, barcode image in png file format supports transparent background setting.
To generate transparent background barcode image in C# class, you need apply the four barcode property settings.
  • BackColor: Its value shall be Color.Transparent.
  • ForeColor: Barcode bar module color.
  • TextColor: It usually is the same as ForeColor.
  • Format: The image format shall be System.Drawing.Imaging.ImageFormat.Png
Here is an EAN-13 barcode generation example.

Please copy the following Visual C# demo code to your project for a transparent barcode symbol implementation. You can store the scannable barcode images in database with further C# coding.
            Linear barcode = new Linear();

            // 12 digits EAN-13 barcode data
            barcode.Data = "123456789012";
            // Barcode symbology type.
            barcode.Type = BarcodeType.EAN13;

            barcode.ForeColor = Color.White;
            barcode.BackColor = Color.Transparent;
            barcode.TextColor = Color.White;
            barcode.Format = System.Drawing.Imaging.ImageFormat.Png;






How to create high resolution barcode image using C# barcode generator?

Top
To create a barcode image for printing, your barcode image resolution should be higher than the printer's resolution. To create a high resolution barcode image, you need apply the two settings:

  • Format: You need choose image format as PNG, JPEG, or Bitmap. Please do not choose GIF. The GIF format does not support resolution setting.
  • Resolution: The value of the resolution should be larger than your printer's resolution.




How to Use C# to Encode Raster Image Formats (JPEG, PNG, GIF, BMP, TIFF)

Top
Users can use C# code to generate a barcode image and encode it into several image file format:

  • JPEG/JPG: a commonly used method of lossy compression for digital images.
  • PNG: Portable Network Graphics is a raster-graphics file format that supports lossless data compression.
  • BMP/Bitmap: The BMP file format or bitmap, is a raster graphics image file format used to store bitmap digital images.
  • GIF: The Graphics Interchange Format is a bitmap image format.
  • TIFF: Tagged Image File Format, a file format for storing images.
Please see as below. (UPC-A is the sample barcode type encoding 12 number digit with check character automatically added).
Developers can adjust other barcode settings, in order to enlarge barcode picture to fixed size in C# by setting width/height, manage barcode label rotation, set unit of measure to centimeter/pixel, or define encrypted barcode color.
   Linear upc_a = new Linear();
upc_a.Type = BarcodeType.UPCA;
upc_a.Data = "12345678901";

// Encode UPC-A barcode into jpeg file format and save it to C:\
upc_a.Format = System.Drawing.Imaging.ImageFormat.Jpeg;
upc_a.drawBarcode("c://csharp_upca.jpeg");

/*
Encode UPC-A barcode into png, gif, bmp or tiff file format:
upc_a.Format = System.Drawing.Imaging.ImageFormat.Png;
upc_a.drawBarcode("c://csharp_upca.png");

upc_a.Format = System.Drawing.Imaging.ImageFormat.Gif;
upc_a.drawBarcode("c://csharp_upca.gif");

upc_a.Format = System.Drawing.Imaging.ImageFormat.bmp;
upc_a.drawBarcode("c://csharp_upca.bmp");

upc_a.Format = System.Drawing.Imaging.ImageFormat.tiff;
upc_a.drawBarcode("c://csharp_upca.tiff");
*/

How to Use C# to generate barcodes in Vector images (SVG & EPS)

Top
Using C# Barcode Generator library, you can easily generate barcodes with vector image formats:

  • SVG: Scalable Vector Graphics (SVG) is a web-friendly vector file format. It is the only vector image supported by web browsers.
  • EPS: Encapsulated PostScript (EPS) is a Document Structuring Convention (DSC) conforming PostScript document format usable as a graphics file format.


How to create barcodes in SVG file format using C#

Using C# barcode generator library, you can easily output barcodes to:

  • a SVG file
  • SVG stream object in C#
  • SVG data in byte array in C# program


The C# source code to output barcode to SVG file
String outputFilePath = Path.Combine(RootPath, "code128.svg");

Linear linear = new Linear();
linear.Type = BarcodeType.CODE128;
linear.Data = "Code 128";

linear.UOM = UnitOfMeasure.INCH;
linear.X = 0.02F;
linear.Y = 1.0F;

linear.drawBarcode2SVG(outputFilePath);


The C# source code to generate barcode to SVG in stream object.
using (FileStream fs = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
{
    Linear linear = new Linear();
    linear.Type = BarcodeType.CODE128;
    linear.Data = "Code 128";

    linear.UOM = UnitOfMeasure.INCH;
    linear.X = 0.02F;
    linear.Y = 1.0F;

    linear.drawBarcode2SVG(fs);
}


The C# source code to generate barcode to SVG in byte array
Linear linear = new Linear();
linear.Type = BarcodeType.CODE128;
linear.Data = "Code 128";

linear.UOM = UnitOfMeasure.INCH;
linear.X = 0.02F;
linear.Y = 1.0F;

byte[] dataBytes = linear.drawBarcode2SVGAsBytes();
File.WriteAllBytes(outputFilePath, dataBytes);




How to create barcodes in EPS file format using C#

Same as SVG, using C# barcode generator library, you can easily output barcodes to:

  • a EPS file
  • EPS stream object in C#
  • EPS data in byte array in C# program


Using method drawBarcode2EPS(string filepath) to create barcode to EPS file using C#.
String outputFilePath = Path.Combine(RootPath, "code128.eps");

Linear linear = new Linear();
linear.Type = BarcodeType.CODE128;
linear.Data = "Code 128";

linear.UOM = UnitOfMeasure.INCH;
linear.X = 0.02F;
linear.Y = 1.0F;

linear.drawBarcode2EPS(outputFilePath);


Using method drawBarcode2EPS(Stream object) to create barcode to EPS in a Stream object.
using (FileStream fs = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
{
    Linear linear = new Linear();
    linear.Type = BarcodeType.CODE128;
    linear.Data = "Code 128";

    linear.UOM = UnitOfMeasure.INCH;
    linear.X = 0.02F;
    linear.Y = 1.0F;

    linear.drawBarcode2EPS(fs);
}


Using method drawBarcode2EPSAsBytes() to create barcode to EPS in byte array.
Linear linear = new Linear();
linear.Type = BarcodeType.CODE128;
linear.Data = "Code 128";

linear.UOM = UnitOfMeasure.INCH;
linear.X = 0.02F;
linear.Y = 1.0F;

byte[] dataBytes = linear.drawBarcode2EPSAsBytes();
File.WriteAllBytes(outputFilePath, dataBytes);

C#.NET Barcode Generation Guide for Supported Barcode Images

Top

.NET Barcode Control DLL for C# - Barcodes Generation













OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.