IRONSOFTWAREHOME

C# & VB .NET Code Samples

C# VB PDF .NET : Barcode QuickstartBarcode Quickstart
using IronBarCode;
using System.Drawing;

// Reading a barcode is easy with IronBarcode!
var resultFromFile = BarcodeReader.Read(@"file/barcode.png"); // From a file
var resultFromBitMap = BarcodeReader.Read(new Bitmap("barcode.bmp")); // From a bitmap
var resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")); // From an image file
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf"); // From PDF use ReadPdf

// To configure and fine-tune barcode reading, utilize the BarcodeReaderOptions class
var myOptionsExample = new BarcodeReaderOptions
{
    // Choose a reading speed from: Faster, Balanced, Detailed, ExtremeDetail
    // There is a tradeoff in performance as more detail is set
    Speed = ReadingSpeed.Balanced,

    // Reader will stop scanning once a single barcode is found (if set to true)
    ExpectMultipleBarcodes = true,

    // By default, all barcode formats are scanned for
    // Specifying a subset of barcode types to search for would improve performance
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,

    // Utilize multiple threads to read barcodes from multiple images in parallel
    Multithreaded = true,

    // Maximum threads for parallelized barcode reading
    // Default is 4
    MaxParallelThreads = 2,

    // The area of each image frame in which to scan for barcodes
    // Specifying a crop area will significantly improve performance and avoid noisy parts of the image
    CropArea = new Rectangle(),

    // Special setting for Code39 barcodes
    // If a Code39 barcode is detected, try to read with both the base and extended ASCII character sets
    UseCode39ExtendedMode = true
};

// Read with the options applied
var results = BarcodeReader.Read("barcode.png", myOptionsExample);

// Create a barcode with one line of code
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

// After creating a barcode, we may choose to resize
myBarcode.ResizeTo(400, 100);

// Save our newly-created barcode as an image
myBarcode.SaveAsImage("EAN8.jpeg");

// Get the barcode as an image for further processing
var myBarcodeImage = myBarcode.Image;
NuGet Downloads Badge
PM > Install-Package BarCode

IronBarcode supports various standard formats, from image files (jpeg, png, and jpg) to more programmatic formats where you would want to pass the variables around, such as a bitmap. Furthermore, it also supports external formats such as PDF, allowing IronBarcode to integrate seamlessly in any codebase, giving developers flexibility with file formats and variables.

Aside from being a barcode reader for all file formats, IronBarcode also doubles as a barcode generator that supports all standard encoding and formatting, such as the EAN8, Code128, and Code39. Setting the barcode generator up only takes two lines of code. With a low barrier of entry and plenty of customization options for developers, IronBarcode is the number one choice for all situations related to barcodes.

Barcode Reader and Barcode Generator in C#

  1. var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeEncoding.EAN8);
  2. Image myBarcodeImage = myBarcode.ToImage();
  3. myBarcode.ResizeTo(400, 100);
  4. var resultFromFile = BarcodeReader.Read(@"file/barcode.png");
  5. var myOptionsExample = new BarcodeReaderOptions { /* Options */ };

Barcode Writer

We first import the necessary libraries such as IronBarCode and System.Drawing, and instantiate BarcodeWriter to create a barcode with the string value of 12345 with the format of EAN8. We then save the generated barcode as an image in the desired format. There are various options for this as IronBarcode supports creating the barcode as an Image as well as a Bitmap.

Advanced Barcode Writer

As seen from above, generating a barcode using IronBarcode requires only two lines of code and saving it as a file for later usage. IronBarcode further extends this by providing developers with a plethora of options to customize the barcode to match the situation.

We can use the ResizeTo method and pass in the height and width to resize the barcode image.

Barcode Reader

Like the above, we first instantiate BarcodeReader, pass the file path to the Read method, and save it as a variable to use later and manipulate the barcode object. There are specified methods for reading external formats such as PDF with ReadPdf; however, for general image formats and bitmaps, we would use Read.

BarcodeReaderOptions

IronBarcode allows developers to scan barcodes from standard file format. However, there are situations where the developers want to fine-tune the behavior of the BarcodeReaderOptions class, especially in cases where it is reading a batch of barcode files programmatically. This is where BarcodeReaderOptions comes in. IronBarcode lets you fully customize things such as the speed at which it reads with Speed, whether multiple barcodes are expected in the file with ExpectMultipleBarcodes, and what kind of barcodes they are with the property ExpectBarcodeTypes. This allows developers to run multiple threads to read barcodes from multiple images in parallel, as well as control the number of threads used when doing parallel reading.

These are just some of the properties that showcase the power of IronBarcode. For a complete list, please refer to the documentation here.

Learn to Create Barcodes with Our Detailed Guide! Read

Human Support Directly From Our Development Team

Whether it's product, integration or licensing queries, the Iron product development team is on hand to support all of your questions. Get in touch and start a dialog with Iron to make the most of our library in your project.

Recognizes 1D and 2D Barcodes in .NET Core, .NET Standard and .NET Framework

IronBarcode .NET barcode library reads any type of barcode within the BarcodeEncoding Enum. It recognizes barcodes in .NET Core, .NET Standard and .NET Framework.

To save time and improve efficiency for inventory workflows, IronBarcode recommends one-dimensional (1D) or linear barcodes, including the traditional and established barcode types such as UPC and EAN codes. Points of sale services across the glove usually use UPC (Universal Product Code) barcodes (including its variations UPC-A and UPC-E). It benefits the target consumer by making it easier to identify and track product features in warehouses and at checkout. Where UPCA is limited to having only numerical contentof 12 to 13 digits long, UPCE supports content between 8 to 13 digits.

Like UPC, European markets use EAN barcodes to label consumer goods for point-of-sale scanning. Its variant includes EAN-13 as the default, whereas EAN-8 is used for limited packaging spaces, like candies. In addition to their flexibility, as a high-density barcode, EAN-13 encodes larger data sets compactly.

1D barcodes do not end there.

The automotive and defense industry utilizes Code 39 barcodes. Its title axplains its ability to encode 39 characters (now revised to 43). Similarly, Code 128-character set and high data density. Continuing with logistics, the packaging industry prefers ITF (Interleaved 2 of 5) barcodes to label packaging materials, such as corrugated sheets due to their high printing tolerance. Whereas, MSI is preferred for product indentification and inventory management.

The Pharma industry utilizes Pharmaceutical Binary COde. Whereas RSS 14 (Reduced Space Symbologies) and Databar barcodes are a 1D and 2D barcode hybrid. It is a healthcare favorite to mark small items. Similar to Code 128 barcodes, Codabar is a logistics and healthcare favorite as well. It works without a computer, readable from a dot-matrix printer output.

2D barcodes include Aztec, Data Matrix, Data Bar, IntelligentMail, Maxicode, QR code. Used in different industries, Aztec is used in the transportation industry on tickets and boarding passes with readability in lower resolution. While IntelligentMail is limited to a specific purpose in US Mail, Maxicode is utilized to standardize shipment tracking.

The widest known amongst barcodes is the QR code. It has a plethora of purposes from B2B to B2C due to its flexibility, fault tolerance, readability, various data support such as numeric, alphanumeric, byte/binary, and Kanji.

Once the type is finalized, IronBarcode - the leading barcode generator takes it from there!

Begin Your Barcode Generation and Reading Project with .NET Barcode Reader

Reading barcode types in .NET is now a breeze with IronBarcode's versatile, advanced, and efficient library.

Where do you begin?

Install IronBarcode's NuGet package or manually install the DLL to your project or your globally assembly cache. You are now one step closer to producing a C# Barcode image scanner application in one live of code. Extract barcode images, values, encoding types, binary data (if any) and then output it all to the console.

TryHarder - Deeper Scans for Skewed Barcode Formats

Adding IronBarcode's TryHarder variable to the QuicklyReadOneBarcode method makes the application try harder, albeit consuming more time, but more thoroughly for analyzing obscured, skewed, or corrupted QR code image formats.

Feel Free to Specify Multiple Formats

You can specify barcode encoding(s) that you are looking for, or specify multiple formats - IronBarcode empowers you with unlimited barcode analysis tools.

You can improve barcode reading performance and accuracy. You can specify various barcode formats simultaneously with the pipe character or 'Bitwize OR'. Alternatively, achieve more specificity and quality with the BarcodeReader.ReadASingleBarcode Method.

Read Barcodes from PDF Documents, to Scans, to Multithreading

If your next project is reading a scanned PDF document and looking for all the 1D barcodes, again IronBarcode will not disappoint. It is similar to reading a single barcode from a single document, except now there is added information about the page number the barcode belongs to.

Similarly, the same result is achieved from a multi-frame TIFF. It is treated similarly to a PDF in this respect.

Is multithreading bothering you? If so, it is supported with IronBarcode!

To read mulitple documents, you can achieve better results with IronBarcode, by creating a list of documents and using the BarcodeReader.ReadBarcodesMultithreaded method. This uses multiple threads and potentially all your CPU cores for the barcode scanning process and can be exponentially faster than reading barcodes one at a time.

Worrying about Imperfect Images is in the Past with Perfect Barcode Generator

In the real world, users may wish to scan a barcode that is not perfect screenshots or PNG images or photographs. Conventional open source .NET barcode generators and reader libraries would make it impossible to read any less-than-perfect image format. However, IronBarcode makes this incredibly straightforward.

The TryHarder method of QuicklyReadOneBarcode results in IronBarcode to deskew and read barcodes from imperfect digital samples.

Photographs, Scans, and Thumbnails

If a photograph is skewed, set specific barcode rotation and image correction to correct the digital noise, skewness, perspective, and rotation reasonably expected from a cellphone camera.

Similarly, reading QR codes and PDF-417 barcodes from a scanned PDF requires setting an appropriate level of barcode rotation correction and barcode image correction to lightly clean the document. However, caution is practiced by not over-specifying and compromising performance.

If you have a corrupted barcode thumbnail then the IronBarcode reader methods automatically detect barcode images that are too small, and upscales, and cleans all the digital noise associated with thumbnailing; making them readable again.

Things could not have been made easier for a developer!

Built for easy use in .NET Core Projects

Get started in minutes with a few lines of code. Built for .NET Core, .NET Standard, and Framework as an easy to use single DLL; without dependencies; supporting 32 & 64 bit; in any .NET Language. Use in Web, Cloud, Desktop or Console Applications; supporting Mobile & Desktop devices. You can download the software product from this link.

Summing Up IronBarcode - For Creating and Manipulating Barcode Images

As IronBarcode facilitates the creation, resizing, and saving of various barcode types and formats, there is no reason to not begin with it right away!

With the Fluent API, use the generated barcode class to set margins, resize, and annotate barcodes. Then save as images with IronOCR automatically assuming the correct image type from a file name. Whether it is GIF, HTML file, HTML tag, JPEG, PNG, TIFF, and Windows Bitmaps.

The StampToExistingPdfPage method allows a barcode to be generated and stamped onto an existing PDF. It is useful when editing a generic PDF or adding an internal identification number to a document via a barcode.

Connect with LIVE 24/7 human support right away. Whether you have a question or require project support; begin with our 30-day trial key, benefit from our broad documentation resource in easy-to-understand English, or benefit from our lifetime licensing from $999.

Supports:

  • .NET Core 2.0 and above
  • .NET Framework 4.0 and above support C#, VB, F#
  • Microsoft Visual Studio. .NET Development IDE Icon
  • NuGet Installer Support for Visual Studio
  • JetBrains ReSharper C# language assistant compatible
  • Microsoft Azure C# .NET  hosting platform compatible

Licensing & Pricing

Free community development licenses. Commercial licenses from $999.

View Full License Options

Barcode & QR Tutorials for C# & VB .NET

Tutorial + Code Examples Reading Barcodes in C# | .NET Tutorial
C#.NETBarcodeQR
Frank Walker .NET Product Developer

Read Barcodes & QRs | C# VB .NET Tutorial

See How Frank uses IronBarcode to Read Barcodes from Scans, Photos, & PDF documents inside his C# .NET Barcode Application...

View Frank's Barcode Reading Tutorial
Writing Barcode Tutorial + Code Examples in C# & VB.NET
C#.NETBarcode
Francesca Miller Junior .NET Engineer

Generating Barcode Images in C# or VB.NET

Francesca shares some tips and tricks for writing Barcodes to Images in C# or VB Applications. See how to write the barcodes and all the options available to you with IronBarcode...

See Francesca's Barcode Tutorial
Tutorial + Code Examples VB.NET PDF Creation and Editing | VB.NET & ASP.NET PDF
QR.NETC#VB
Jennifer Wright Application Architecture Lead

Tutorial for Writing QR codes in C# & VB .NET Applications

Jenny's Team use IronBarcode to write thousands of QRs per day. See their tutorial on getting the most out of IronBarcode...

QR Writing Tutorial from Jenny's Team

Thousands of developers use IronBarcode for...

Accounting and Finance Systems

  • # Receipts
  • # Reporting
  • # Invoice Printing
Add PDF Support to ASP.NET Accounting and Finance Systems

Business Digitization

  • # Documentation
  • # Ordering & Labelling
  • # Paper Replacement
C# Business Digitization Use Cases

Enterprise Content Management

  • # Content Production
  • # Document Management
  • # Content Distribution
.NET CMS PDF Support

Data and Reporting Applications

  • # Performance Tracking
  • # Trend Mapping
  • # Reports
C# PDF Reports
Join Them Today
Iron Software Enterprise .NET Component Developers
C# Library Developers

Thousands of corporations, governments, SMEs and developers alike trust Iron software products.

Iron's team have over 10 years experience in the .NET software component market.

Iron Customer Icon
Iron Customer Icon
Iron Customer Icon
Iron Customer Icon
Iron Customer Icon
Iron Customer Icon
Iron Customer Icon
Iron Customer Icon

Ready to Get Started?

Nuget Downloads 2,422,100Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required