C# + VB.Net: Barcode Quickstart Barcode Quickstart
using IronBarCode;
using System.Drawing;

// Creating a barcode is as simple as:
var myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);

// And save our barcode as in image:
myBarcode.SaveAsImage("EAN8.jpeg");

Image myBarcodeImage = myBarcode.Image; // Can be used as Image
Bitmap myBarcodeBitmap = myBarcode.ToBitmap(); // Can be used as Bitmap

// 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
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf"); // From PDF use ReadPdf

// After creating a barcode, we may choose to resize and save which is easily done with:
var myNewBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8);
myNewBarcode.ResizeTo(400, 100);
myNewBarcode.SaveAsImage("myBarcodeResized.jpeg");

// To set more options and optimization with your Barcode Reading,
// Please utilize the BarcodeReaderOptions paramter of read:
BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{

    // Choose a 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 barcode is found, unless set to true
    ExpectMultipleBarcodes = true,

    // By default, all barcode formats are scanned for.
    // Specifying one or more, performance will increase.
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,

    // Utilizes multiple threads to reads barcodes from multiple images in parallel.
    Multithreaded = true,

    // Maximum threads for parallel. Default is 4
    MaxParallelThreads = 2,

    // The area of each image frame in which to scan for barcodes.
    // Will improve perfornace significantly and avoid unwanted results and avoid noisy parts of the image.
    CropArea = new System.Drawing.Rectangle(),

    // Special Setting for Code39 Barcodes.
    // If a Code39 barcode is detected. Try to use extended mode for the full ASCII Character Set
    UseCode39ExtendedMode = true
};

// And, apply:
var results = BarcodeReader.Read("barcode.png", myOptionsExample);
Imports IronBarCode
Imports System.Drawing

' Creating a barcode is as simple as:
Private myBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)

' And save our barcode as in image:
myBarcode.SaveAsImage("EAN8.jpeg")

Dim myBarcodeImage As Image = myBarcode.Image ' Can be used as Image
Dim myBarcodeBitmap As Bitmap = myBarcode.ToBitmap() ' Can be used as Bitmap

' Reading a barcode is easy with IronBarcode:
Dim resultFromFile = BarcodeReader.Read("file/barcode.png") ' From a file
Dim resultFromBitMap = BarcodeReader.Read(New Bitmap("barcode.bmp")) ' From a bitmap
Dim resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg")) ' From an image
Dim resultFromPdf = BarcodeReader.ReadPdf("file/mydocument.pdf") ' From PDF use ReadPdf

' After creating a barcode, we may choose to resize and save which is easily done with:
Dim myNewBarcode = BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8)
myNewBarcode.ResizeTo(400, 100)
myNewBarcode.SaveAsImage("myBarcodeResized.jpeg")

' To set more options and optimization with your Barcode Reading,
' Please utilize the BarcodeReaderOptions paramter of read:
Dim myOptionsExample As New BarcodeReaderOptions() With {
	.Speed = ReadingSpeed.Balanced,
	.ExpectMultipleBarcodes = True,
	.ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
	.Multithreaded = True,
	.MaxParallelThreads = 2,
	.CropArea = New System.Drawing.Rectangle(),
	.UseCode39ExtendedMode = True
}

' And, apply:
Dim results = BarcodeReader.Read("barcode.png", myOptionsExample)

The BarcodeWriter.CreateBarcode class can be used to create barcodes and QR codes from strings, numbers, or binary data and encode to an appropriate format. We can then use the SaveAsImage() method to export as an image, or other easy saving methods to save to a PDF, HTML, System.Drawing.Image, stream, or Bitmap object.

Likewise, we can read barcodes using the BarcodeReader class. The easiest method to use is the BarcodeReader.Read method, as shown above.

Do note all of the various options set in BarcodeReaderOptions that allow you to customise your reading to be faster, more intensive, stop scanning after reaching one barcode to save time, specify specific types of barcode to search for, and utilize multithreading, among other customization options.

C# + VB.Net: Reading Barcodes and QR Reading Barcodes and QR
using IronBarCode;
using System;
using System.Drawing;  // Include a reference to System.Drawing.Dll


/*** GET STARED WITH BARCODE READING ***/

// Read almost any Barcode or QR in 1 line of Code.
BarcodeResult QRResult = BarcodeReader.QuicklyReadOneBarcode("QR.png");

// Work with the results
if (QRResult != null)
{
    string Value = QRResult.Value;
    Bitmap Img = QRResult.BarcodeImage;
    BarcodeEncoding BarcodeType = QRResult.BarcodeType;
    byte[] Binary = QRResult.BinaryValue;
    Console.WriteLine(QRResult.Value);
}

// Setting the optional BarcodeEncoding and TryHarder settings will improve performance
BarcodeResult QRBetterResult = BarcodeReader.QuicklyReadOneBarcode("QR.png", BarcodeEncoding.QRCode, true);

// Multiple Barcode Formats May be Specified using the | Pipe Operator
BarcodeResult FormatsResult = BarcodeReader.QuicklyReadOneBarcode("QR.png", BarcodeEncoding.QRCode | BarcodeEncoding.PDF417 | BarcodeEncoding.Code128);



/***  READING MULTIPLE BARCODES FROM 1 IMAGE OR PDF DOCUMENT ***/

// Multiple barcodes may be scanned up from a single document or image.  A PDF document may also used as the input image
BarcodeResult[] PDFResults = BarcodeReader.QuicklyReadAllBarcodes("MultipleBarcodes.pdf", BarcodeEncoding.AllOneDimensional, true);

// Work with the results
foreach (var PDFResult in PDFResults)
{
    string Value = PDFResult.Value;
    Bitmap Img = PDFResult.BarcodeImage;
    BarcodeEncoding BarcodeType = PDFResult.BarcodeType;
    byte[] Binary = PDFResult.BinaryValue;
    Console.WriteLine(PDFResult.Value);
}

// Multi frame TIFF and GIF images can also be scanned, and multiple threads will be used automatically in the background for improved performance
BarcodeResult[] MultiFrameResults = BarcodeReader.ReadBarcodesFromMultiFrameTiff("Multiframe.tiff", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.Low, BarcodeReader.BarcodeImageCorrection.None);

// The BarcodeResult.ReadBarcodesMultiThreaded method allows for faster barcode scanning of multiple images or PDFs.  All threads are automatically managed by IronBarCode.
var ListOfDocuments = new[] { "Image1.png", "image2.JPG", "image3.pdf" };
PagedBarcodeResult[] BatchResults = BarcodeReader.ReadBarcodesMultiThreaded(ListOfDocuments);





/***  READING BARCODES FROM ONLY PART OF AN IMAGE OR DOCUMENT ***/

//  All BarcodeResult.Read methods all have counterparts that support only scanning for barcodes in specific parts of documents.
//  This really helps performance when  processing batches of similar documents, forms, tickets, financial documents etc.

System.Drawing.Rectangle MyCropArea = new Rectangle { X = 165, Y = 225, Width = 500, Height = 200 }; // measured in pixels
BarcodeResult[] InvoiceResults = BarcodeReader.ReadAllBarcodesInCropArea("Invoice.Tiff", MyCropArea, BarcodeEncoding.Code128);

//  To read barcodes from only 1 or selected pages of a PDF, the ReadBarcodesFromPdfPage and ReadBarcodesFromPdfPages methods can be used.
//  Page numbers are 1 based (the first page is  1 not zero)
PagedBarcodeResult[] Page3ScanResults = BarcodeReader.ReadBarcodesFromPdfPage("PileofInvoices.pdf", 3, BarcodeEncoding.PDF417);
Imports IronBarCode
Imports System
Imports System.Drawing ' Include a reference to System.Drawing.Dll


'''* GET STARED WITH BARCODE READING **

' Read almost any Barcode or QR in 1 line of Code.
Private QRResult As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("QR.png")

' Work with the results
If QRResult IsNot Nothing Then
	Dim Value As String = QRResult.Value
	Dim Img As Bitmap = QRResult.BarcodeImage
	Dim BarcodeType As BarcodeEncoding = QRResult.BarcodeType
	Dim Binary() As Byte = QRResult.BinaryValue
	Console.WriteLine(QRResult.Value)
End If

' Setting the optional BarcodeEncoding and TryHarder settings will improve performance
Dim QRBetterResult As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("QR.png", BarcodeEncoding.QRCode, True)

' Multiple Barcode Formats May be Specified using the | Pipe Operator
Dim FormatsResult As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("QR.png", BarcodeEncoding.QRCode Or BarcodeEncoding.PDF417 Or BarcodeEncoding.Code128)



'''*  READING MULTIPLE BARCODES FROM 1 IMAGE OR PDF DOCUMENT **

' Multiple barcodes may be scanned up from a single document or image.  A PDF document may also used as the input image
Dim PDFResults() As BarcodeResult = BarcodeReader.QuicklyReadAllBarcodes("MultipleBarcodes.pdf", BarcodeEncoding.AllOneDimensional, True)

' Work with the results
For Each PDFResult In PDFResults
	Dim Value As String = PDFResult.Value
	Dim Img As Bitmap = PDFResult.BarcodeImage
	Dim BarcodeType As BarcodeEncoding = PDFResult.BarcodeType
	Dim Binary() As Byte = PDFResult.BinaryValue
	Console.WriteLine(PDFResult.Value)
Next PDFResult

' Multi frame TIFF and GIF images can also be scanned, and multiple threads will be used automatically in the background for improved performance
Dim MultiFrameResults() As BarcodeResult = BarcodeReader.ReadBarcodesFromMultiFrameTiff("Multiframe.tiff", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.Low, BarcodeReader.BarcodeImageCorrection.None)

' The BarcodeResult.ReadBarcodesMultiThreaded method allows for faster barcode scanning of multiple images or PDFs.  All threads are automatically managed by IronBarCode.
Dim ListOfDocuments = { "Image1.png", "image2.JPG", "image3.pdf" }
Dim BatchResults() As PagedBarcodeResult = BarcodeReader.ReadBarcodesMultiThreaded(ListOfDocuments)





'''*  READING BARCODES FROM ONLY PART OF AN IMAGE OR DOCUMENT **

'  All BarcodeResult.Read methods all have counterparts that support only scanning for barcodes in specific parts of documents.
'  This really helps performance when  processing batches of similar documents, forms, tickets, financial documents etc.

Dim MyCropArea As System.Drawing.Rectangle = New Rectangle With {
	.X = 165,
	.Y = 225,
	.Width = 500,
	.Height = 200
}
Dim InvoiceResults() As BarcodeResult = BarcodeReader.ReadAllBarcodesInCropArea("Invoice.Tiff", MyCropArea, BarcodeEncoding.Code128)

'  To read barcodes from only 1 or selected pages of a PDF, the ReadBarcodesFromPdfPage and ReadBarcodesFromPdfPages methods can be used.
'  Page numbers are 1 based (the first page is  1 not zero)
Dim Page3ScanResults() As PagedBarcodeResult = BarcodeReader.ReadBarcodesFromPdfPage("PileofInvoices.pdf", 3, BarcodeEncoding.PDF417)

The BarcodeReader.QuicklyReadOneBarcode method in the IronBarCode namespace is an incredibly useful utility for reading barcodes for in the .NET framework. By specifying a barcode encoding format, we can greatly improve performance, and by setting the TryHarder variable to True, we can cause it to automatically correct for perspective and digital noise.

The QuicklyReadAllBarcodes method is very similar; however, it can be used to read multiple barcodes for multipage documents such as PDFs or multipage TIFFs.

We can also see from this example that we may choose to only read barcodes from a specific area of a document using a System.Drawing.Rectangle. This is very useful when we’re reading barcodes from regular locations within documents such as memos, invoices, or checks.

C# + VB.Net: Imperfect Barcodes and Image Correction Imperfect Barcodes and Image Correction
using IronBarCode;
using System.Linq;

// Choose which filters are to be applied (in order);
var filtersToApply = new ImageFilterCollection() {
    new SharpenFilter(),
    new InvertFilter(),
    new ContrastFilter(),
    new BrightnessFilter(),
    new AdaptiveThresholdFilter(),
    new BinaryThresholdFilter()
};


BarcodeReaderOptions myOptionsExample = new BarcodeReaderOptions()
{
    // Set chosen filters in BarcodeReaderOptions:
    ImageFilters = filtersToApply,

    // Other Barcode Reader Options:
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
};

// And, apply with a Read:
BarcodeResults results = BarcodeReader.Read("screenshot.png", myOptionsExample);

AnyBitmap[] filteredImages = results.FilterImages();

// Export file to disk
for (int i = 0; i < filteredImages.Count(); i++)
  filteredImages[i].SaveAs($"{i}_barcode.png");

// Or
results.ExportFilterImagesToDisk("filter-result.jpg");
Imports IronBarCode
Imports System.Linq

' Choose which filters are to be applied (in order);
Private filtersToApply = New ImageFilterCollection() From {
	New SharpenFilter(),
	New InvertFilter(),
	New ContrastFilter(),
	New BrightnessFilter(),
	New AdaptiveThresholdFilter(),
	New BinaryThresholdFilter()
}


Private myOptionsExample As New BarcodeReaderOptions() With {
	.ImageFilters = filtersToApply,
	.Speed = ReadingSpeed.Balanced,
	.ExpectMultipleBarcodes = True
}

' And, apply with a Read:
Private results As BarcodeResults = BarcodeReader.Read("screenshot.png", myOptionsExample)

Private filteredImages() As AnyBitmap = results.FilterImages()

' Export file to disk
For i As Integer = 0 To filteredImages.Count() - 1
  filteredImages(i).SaveAs($"{i}_barcode.png")
Next i

' Or
results.ExportFilterImagesToDisk("filter-result.jpg")

IronBarcode has many filters to choose from that are easily applied in the BarcodeReaderOptions. Select the filters that may improve reading of your image such as Sharpen, Invert (colors), and Contrast. Please keep in mind that the order in which you choose them are the order that they are applied.

C# + VB.Net: Creating Barcodes Images Creating Barcodes Images
using IronBarCode;
using System.Drawing;  // Include a reference to System.Drawing.Dll



/*** CREATING BARCODE IMAGES ***/

// Shorthand:: Create and save a barcode in a single line of code
BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8).ResizeTo(400, 100).SaveAsImage("EAN8.jpeg");


/*****  IN-DEPTH BARCODE CREATION OPTIONS *****/

// BarcodeWriter.CreateBarcode creates a GeneratedBarcode which can be styles and exported as an Image object or File
GeneratedBarcode MyBarCode = BarcodeWriter.CreateBarcode("Any Number, String or Binary Value", BarcodeWriterEncoding.Code128);

// Style the Barcode in a fluent LINQ style fashion
MyBarCode.ResizeTo(300, 150).SetMargins(20).AddAnnotationTextAboveBarcode("Example EAN8 Barcode").AddBarcodeValueTextBelowBarcode();
MyBarCode.ChangeBackgroundColor(Color.LightGoldenrodYellow);

// Save MyBarCode as an image file
MyBarCode.SaveAsImage("MyBarCode.png");
MyBarCode.SaveAsGif("MyBarCode.gif");
MyBarCode.SaveAsHtmlFile("MyBarCode.html");
MyBarCode.SaveAsJpeg("MyBarCode.jpg");
MyBarCode.SaveAsPdf("MyBarCode.Pdf");
MyBarCode.SaveAsPng("MyBarCode.png");
MyBarCode.SaveAsTiff("MyBarCode.tiff");
MyBarCode.SaveAsWindowsBitmap("MyBarCode.bmp");

// Save MyBarCode as a .NET native objects
Image MyBarCodeImage = MyBarCode.Image;
Bitmap MyBarCodeBitmap = MyBarCode.ToBitmap();

byte[] PngBytes = MyBarCode.ToPngBinaryData();

using (System.IO.Stream PdfStream = MyBarCode.ToPdfStream())
{
    // Stream barcode image output also works for GIF,JPEG, PDF, PNG, BMP and TIFF
}

// Save MyBarCode as HTML files and tags
MyBarCode.SaveAsHtmlFile("MyBarCode.Html");
string ImgTagForHTML = MyBarCode.ToHtmlTag();
string DataURL = MyBarCode.ToDataUrl();

// Save MyBarCode to a new PDF, or stamp it in any position on any page(s) of an existing Document
MyBarCode.SaveAsPdf("MyBarCode.Pdf"); 
MyBarCode.StampToExistingPdfPage("ExistingPDF.pdf", 200, 50, 1);  // position 200x50 on page 1
MyBarCode.StampToExistingPdfPages("ExistingPDF.pdf", 200, 50, new[] { 1, 2, 3 }, "Password123");  // multiple pages of an encrypted PDF
Imports IronBarCode
Imports System.Drawing ' Include a reference to System.Drawing.Dll



'''* CREATING BARCODE IMAGES **

' Shorthand:: Create and save a barcode in a single line of code
BarcodeWriter.CreateBarcode("12345", BarcodeWriterEncoding.EAN8).ResizeTo(400, 100).SaveAsImage("EAN8.jpeg")


'''***  IN-DEPTH BARCODE CREATION OPTIONS ****

' BarcodeWriter.CreateBarcode creates a GeneratedBarcode which can be styles and exported as an Image object or File
Dim MyBarCode As GeneratedBarcode = BarcodeWriter.CreateBarcode("Any Number, String or Binary Value", BarcodeWriterEncoding.Code128)

' Style the Barcode in a fluent LINQ style fashion
MyBarCode.ResizeTo(300, 150).SetMargins(20).AddAnnotationTextAboveBarcode("Example EAN8 Barcode").AddBarcodeValueTextBelowBarcode()
MyBarCode.ChangeBackgroundColor(Color.LightGoldenrodYellow)

' Save MyBarCode as an image file
MyBarCode.SaveAsImage("MyBarCode.png")
MyBarCode.SaveAsGif("MyBarCode.gif")
MyBarCode.SaveAsHtmlFile("MyBarCode.html")
MyBarCode.SaveAsJpeg("MyBarCode.jpg")
MyBarCode.SaveAsPdf("MyBarCode.Pdf")
MyBarCode.SaveAsPng("MyBarCode.png")
MyBarCode.SaveAsTiff("MyBarCode.tiff")
MyBarCode.SaveAsWindowsBitmap("MyBarCode.bmp")

' Save MyBarCode as a .NET native objects
Dim MyBarCodeImage As Image = MyBarCode.Image
Dim MyBarCodeBitmap As Bitmap = MyBarCode.ToBitmap()

Dim PngBytes() As Byte = MyBarCode.ToPngBinaryData()

Using PdfStream As System.IO.Stream = MyBarCode.ToPdfStream()
	' Stream barcode image output also works for GIF,JPEG, PDF, PNG, BMP and TIFF
End Using

' Save MyBarCode as HTML files and tags
MyBarCode.SaveAsHtmlFile("MyBarCode.Html")
Dim ImgTagForHTML As String = MyBarCode.ToHtmlTag()
Dim DataURL As String = MyBarCode.ToDataUrl()

' Save MyBarCode to a new PDF, or stamp it in any position on any page(s) of an existing Document
MyBarCode.SaveAsPdf("MyBarCode.Pdf")
MyBarCode.StampToExistingPdfPage("ExistingPDF.pdf", 200, 50, 1) ' position 200x50 on page 1
MyBarCode.StampToExistingPdfPages("ExistingPDF.pdf", 200, 50, { 1, 2, 3 }, "Password123") ' multiple pages of an encrypted PDF

In this example we see that barcodes of many different types and formats can be created, resized, and saved; possibly even in a single line of code.

Using the Fluent API, the generated barcode class can be used to set margins, resize, and annotate barcodes. They may then be saved as images with IronOCR automatically assuming the correct image type from a file name: GIFs, HTML files, HTML tags, JPEGs, PDFs, PNGs, TIFFs, and Windows Bitmaps.

We also have the StampToExistingPdfPage method, which allows a barcode to be generated and stamped onto an existing PDF. This is useful when editing a generic PDF or adding an internal identification number to a document via a barcode.

C# + VB.Net: Barcode Styling & Annotation Barcode Styling & Annotation
using System;
using IronBarCode;
using System.Drawing;  // Include a reference to System.Drawing.Dll


/*** STYING GENERATED BARCODES  ***/

// BarcodeWriter.CreateBarcode creates a GeneratedBarcode object which allows the barcode to be styled and annotated.
GeneratedBarcode MyBarCode = BarcodeWriter.CreateBarcode("Iron Software", BarcodeWriterEncoding.QRCode); 

// Any text (or commonly, the value of the barcode) can be added to the image in a default or specified font.
// Text positions are automatically centered, above or below.  Fonts that are too large for a given image are automatically scaled down.
MyBarCode.AddBarcodeValueTextBelowBarcode();
MyBarCode.AddAnnotationTextAboveBarcode("This is My Barcode", new Font(new FontFamily("Arial"), 12, FontStyle.Regular, GraphicsUnit.Pixel), Color.DarkSlateBlue);

// Resize, add Margins and Check final Image Dimensions
MyBarCode.ResizeTo(300, 300); // pixels
MyBarCode.SetMargins(0, 20, 0, 20);

int FinalWidth = MyBarCode.Width;
int FinalHeight = MyBarCode.Height;

//Recolor the barcode and its background
MyBarCode.ChangeBackgroundColor(Color.LightGray);
MyBarCode.ChangeBarCodeColor(Color.DarkSlateBlue);
if (!MyBarCode.Verify())
{
    Console.WriteLine("Color contrast should be at least 50% or a barcode may become unreadable.  Test using GeneratedBarcode.Verify()");
}

// Finally save the result
MyBarCode.SaveAsHtmlFile("StyledBarcode.html");


/*** STYING BARCODES IN A SINGLE LINQ STYLE EXPRESSION ***/

// Fluent API
BarcodeWriter.CreateBarcode("https://ironsoftware.com", BarcodeWriterEncoding.Aztec).ResizeTo(250, 250).SetMargins(10).AddBarcodeValueTextAboveBarcode().SaveAsImage("StyledBarcode.png");


/*** STYING QR CODES WITH LOGO IMAGES OR BRANDING ***/

// Use the QRCodeWriter.CreateQrCodeWithLogo Method instead of BarcodeWriter.CreateBarcode
// Logo will automatically be sized appropriately and snapped to the QR grid.

GeneratedBarcode QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("https://visualstudio.microsoft.com/", "visual-studio-logo.png");
QRWithLogo.ResizeTo(500, 500).SetMargins(10).ChangeBarCodeColor(Color.DarkGreen);
QRWithLogo.SaveAsPng("QRWithLogo.Png").SaveAsPdf("MyVerifiedQR.html"); // save as 2 formats 
Imports System
Imports IronBarCode
Imports System.Drawing ' Include a reference to System.Drawing.Dll


'''* STYING GENERATED BARCODES  **

' BarcodeWriter.CreateBarcode creates a GeneratedBarcode object which allows the barcode to be styled and annotated.
Private MyBarCode As GeneratedBarcode = BarcodeWriter.CreateBarcode("Iron Software", BarcodeWriterEncoding.QRCode)

' Any text (or commonly, the value of the barcode) can be added to the image in a default or specified font.
' Text positions are automatically centered, above or below.  Fonts that are too large for a given image are automatically scaled down.
MyBarCode.AddBarcodeValueTextBelowBarcode()
MyBarCode.AddAnnotationTextAboveBarcode("This is My Barcode", New Font(New FontFamily("Arial"), 12, FontStyle.Regular, GraphicsUnit.Pixel), Color.DarkSlateBlue)

' Resize, add Margins and Check final Image Dimensions
MyBarCode.ResizeTo(300, 300) ' pixels
MyBarCode.SetMargins(0, 20, 0, 20)

Dim FinalWidth As Integer = MyBarCode.Width
Dim FinalHeight As Integer = MyBarCode.Height

'Recolor the barcode and its background
MyBarCode.ChangeBackgroundColor(Color.LightGray)
MyBarCode.ChangeBarCodeColor(Color.DarkSlateBlue)
If Not MyBarCode.Verify() Then
	Console.WriteLine("Color contrast should be at least 50% or a barcode may become unreadable.  Test using GeneratedBarcode.Verify()")
End If

' Finally save the result
MyBarCode.SaveAsHtmlFile("StyledBarcode.html")


'''* STYING BARCODES IN A SINGLE LINQ STYLE EXPRESSION **

' Fluent API
BarcodeWriter.CreateBarcode("https://ironsoftware.com", BarcodeWriterEncoding.Aztec).ResizeTo(250, 250).SetMargins(10).AddBarcodeValueTextAboveBarcode().SaveAsImage("StyledBarcode.png")


'''* STYING QR CODES WITH LOGO IMAGES OR BRANDING **

' Use the QRCodeWriter.CreateQrCodeWithLogo Method instead of BarcodeWriter.CreateBarcode
' Logo will automatically be sized appropriately and snapped to the QR grid.

Dim QRWithLogo As GeneratedBarcode = QRCodeWriter.CreateQrCodeWithLogo("https://visualstudio.microsoft.com/", "visual-studio-logo.png")
QRWithLogo.ResizeTo(500, 500).SetMargins(10).ChangeBarCodeColor(Color.DarkGreen)
QRWithLogo.SaveAsPng("QRWithLogo.Png").SaveAsPdf("MyVerifiedQR.html") ' save as 2 formats

In this sample, we see that barcodes may be annotated with text of your choosing or the barcode’s own value using any typeface which is installed on the target machine. If that typeface is not available, an appropriate similar typeface will be chosen. Barcodes may be resized, have margins added, and both the barcode and the background may be recolored. They may then be saved as an appropriate format.

In the final few lines of code, you can see that using our fluent style operators, it’s possible to create and style a barcode in only a few lines of code, similar to System.Linq.

C# + VB.Net: Export Barcodes as HTML Export Barcodes as HTML
using IronBarCode;


/*** EXPORTING BARCODES AS HTML FILES OR TAGS ***/

GeneratedBarcode MyBarCode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128);

// Save as a stand-alone HTML file with no image assets required
MyBarCode.SaveAsHtmlFile("MyBarCode.html");

// Save as a stand-alone HTML image tag which can be served in HTML files, ASPX or MVC Views.  No image assets required, the tag embeds the entire image in its Src contents
string ImgTag = MyBarCode.ToHtmlTag();

// Turn the image into an Html/CSS Data URI.  https://en.wikipedia.org/wiki/Data_URI_scheme
string DataURI = MyBarCode.ToDataUrl();
Imports IronBarCode


'''* EXPORTING BARCODES AS HTML FILES OR TAGS **

Private MyBarCode As GeneratedBarcode = BarcodeWriter.CreateBarcode("1234567890", BarcodeWriterEncoding.Code128)

' Save as a stand-alone HTML file with no image assets required
MyBarCode.SaveAsHtmlFile("MyBarCode.html")

' Save as a stand-alone HTML image tag which can be served in HTML files, ASPX or MVC Views.  No image assets required, the tag embeds the entire image in its Src contents
Dim ImgTag As String = MyBarCode.ToHtmlTag()

' Turn the image into an Html/CSS Data URI.  https://en.wikipedia.org/wiki/Data_URI_scheme
Dim DataURI As String = MyBarCode.ToDataUrl()

Iron Barcode has a very useful feature allowing barcodes to be exported as HTML that is self-contained, such that it has no associated image assets. Everything is contained within the HTML file.

We may export as an HTML file, HTML image tag or to a data URI.

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.

Ask a Question

Finds Multiples QR Code Types

IronBarcode reads and generates the majority of barcode and QR standards including UPC A/E, EAN 8/13, Code 39, Code 93, Code 128, ITF, MSI, RSS 14/Expanded, Databar, CodaBar, QR, Styled QR, Data Matrix, MaxiCode, PDF417, Plessey, and Aztec. Results provide barcode data, type, page, text, and barcode image; ideal for archive or indexing systems.

See Full Function List

Fast & Accurate Reading with Image Pre Processing

IronBarcode automatically pre processes barcode images to improve speed and accuracy. Correcting rotation, noise, distortion and skewing to read scans or live video frames. Multi core, multi thread ready for batch processing server applications. Automatically find one or multiple barcodes in single and multi page documents. Search for specific barcode types or document locations without the need for complex APIs.

Learn More

Built for easy use in .NET Core, Standard & Framework Projects

Get started in minutes with a few lines of code. Built for the .NET 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.

Built for QR, C#, .NET

Get Started Now

Write QR Codes to Multiple Formats

Save or Print to a file or stream, as PDF, JPG, TIFF, GIF, BMP, PNG, or HTML formats. Set colour, quality, rotation, size and text. Use the C# Barcode Programming toolbox along with IronPDF and IronOCR for a full .NET Document Library.

Learn More
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 $749.

Project C# + VB.NET Library Licensing

Project

Developer C# + VB.NET Library Licensing

Developer

Organization C# + VB.NET Library Licensing

Organization

Agency C# + VB.NET Library Licensing

Agency

SaaS C# + VB.NET Library Licensing

SaaS

OEM C# + VB.NET Library Licensing

OEM

View Full License Options  

QR code Tutorials for C# & VB .Net

Tutorial + Code Examples Reading Barcodes in C# | .NET Tutorial

C# .Net Barcode QR

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# .Net Barcode

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 .Net C# 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

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