C# QR Code Reader Library
How to scan, read QR Code from PDF, tiff, Word, Jpeg, bitmap image files using C#
Sample C# source code to read, decode QR Code from documents and images.
In this C# tutorial, you learn how to scan, read QR Code barcode from image, PDF, Tiff files in your C# asp.net web app and Windows application
- Easy to scan, recognize QR Code barcodes from image, PDF files
- Reading QR Code from PDF, Tiff, Office Word, Excel, PowerPoint files and PNG, JPG, GIF, Bitmap image files
- Advanced scanning options to speed up reading
How to scan, read QR Code from PDF, Tiff, image files using C#
- Mature QR Code barcode reading library for C#.NET imaging project with reasonable licensing
- Compatible with .NET Framework 3.0 & above, suitable for Visual Studio 2005 & greater
- Detect and read all QR Code barcodes from documents and image files using C#.NET
- Extract and return recognized QR Code barcode value into data string using C# code
- Read & decode QR Code barcode at any orientation from document image in C#.NET
- Allow users to specify an area on the document or image to recognize QR Code barcode
Scan, read QR Code barcodes from documents and images using C#
XImage.Barcode Reader SDK supports read, decode QR Code barcodes from documents and images, such as Adobe PDF, Microsoft Office Word, Tiff, Jpeg, png image files.
The following demo codes will explain the basic methods to read qr codes.
C#: scan, read QR Code data from Adobe PDF documents
This C#.NET barcode scanning control can also detect all the QR Code barcodes automatically from text editable pdf document or scanned PDF document file.
Besides, by default, the barcode reader and scanner will detect all the QR Code barcodes from the whole PDF document pages.
String inputFilePath = @"C:\1.pdf";
// Open PDF file
PDFDocument doc = new PDFDocument(inputFilePath);
// Initial reader's setting
ReaderSettings settings = new ReaderSettings();
// Set target barcode type
settings.AddTypesToRead(BarcodeType.QRCode);
// Scan barcodes from the document.
Barcode[] result = BarcodeReader.ReadBarcodes(settings, doc);
if (result.Length > 0)
{
foreach (Barcode barcode in result)
Console.WriteLine("Barcode Data: " + barcode.DataString);
}
else
Console.WriteLine("[No Barcode Found]");
C#: scan, read QR Code data from Tiff image files using C#
With RasterEdge .NET Barcode Reader SDK, users are allowed to reading QR Code not only from png, jpeg, bmp and gif image files, but also tiff images.
This is the C# demo code for reading QR Code from tiff image file.
String inputFilePath = @"C:\1.tif";
// Open TIFF file
TIFFDocument doc = new TIFFDocument(inputFilePath);
// Initial reader's setting
ReaderSettings settings = new ReaderSettings();
// Set target barcode type
settings.AddTypesToRead(BarcodeType.QRCode);
// Scan barcodes from the document.
Barcode[] result = BarcodeReader.ReadBarcodes(settings, doc);
if (result.Length > 0)
{
foreach (Barcode barcode in result)
Console.WriteLine("Barcode Data: " + barcode.DataString);
}
else
Console.WriteLine("[No Barcode Found]");
C#: scan, read QR Code data from Jpeg (.jpg) image files using C#
Using this .NET barcode reader control, you can easily detect and decode all QR Code barcodes from loaded image file using C# code.
Supported image file formats are png, jpeg, bmp, tiff and gif. The sample C# code below can help you detect all QR Code barcodes from png and return the decoding values to data string.
String inputFilePath = @"C:\1.jpg";
// Open JPEG file
Bitmap bitmap = new Bitmap(inputFilePath);
// Initial reader's setting
ReaderSettings settings = new ReaderSettings();
// Set target barcode type
settings.AddTypesToRead(BarcodeType.QRCode);
// Scan barcodes from the document.
Barcode[] result = BarcodeReader.ReadBarcodes(settings, bitmap);
if (result.Length > 0)
{
foreach (Barcode barcode in result)
Console.WriteLine("Barcode Data: " + barcode.DataString);
}
else
Console.WriteLine("[No Barcode Found]");
C#: scan, read QR Code data from stream objects using C#
Using barcode reader SDK, you can not only read QR Codes from image document files, you can also scan, read qr code data from stream objects directly using C#.
String inputFilePath = @"C:\1.png";
using (FileStream fs = File.Open(inputFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
// Open PNG stream
Bitmap bitmap = new Bitmap(fs);
// Initial reader's setting
ReaderSettings settings = new ReaderSettings();
// Set target barcode type
settings.AddTypesToRead(BarcodeType.QRCode);
// Scan barcodes from the document.
Barcode[] result = BarcodeReader.ReadBarcodes(settings, bitmap);
if (result.Length > 0)
{
foreach (Barcode barcode in result)
Console.WriteLine("Barcode Data: " + barcode.DataString);
}
else
Console.WriteLine("[No Barcode Found]");
}
C#: scan, read QR Code data from Office Word (.docx) files using C#
This barcode reader control also supports detecting & recognizing QR Code from Word document in C#.NET class application. The QR Code barcode reader scanning area can be accurately specified using C# code. There is no fixed outputting ways to export the QR Code scanning results. Here, we output the decoding result to data string using C# code.
String inputFilePath = @"C:\1.docx";
// Open .docx file
DOCXDocument doc = new DOCXDocument(inputFilePath);
// Initial reader's setting
ReaderSettings settings = new ReaderSettings();
// Set target barcode type
settings.AddTypesToRead(BarcodeType.QRCode);
// Scan barcodes from the document.
Barcode[] result = BarcodeReader.ReadBarcodes(settings, doc);
if (result.Length > 0)
{
foreach (Barcode barcode in result)
Console.WriteLine("Barcode Data: " + barcode.DataString);
}
else
Console.WriteLine("[No Barcode Found]");
More advanced features to read QR Codes
To improve the qr code reading speed, you can scan and read qr code data from image region area, PDF, Tiff pages list. The following demo codes will show how to do it.
C#: scan, read barcodes with multiple barcode types using C#
The C# code below will scan, read multiple barcode types from an image file.
String inputFilePath = @"C:\1.jpg";
// Open JPEG file
Bitmap bitmap = new Bitmap(inputFilePath);
// Initial reader's setting
ReaderSettings settings = new ReaderSettings();
// Set multiple target barcode types to Code128, DataMatrix and QRCode
settings.AddTypesToRead(BarcodeType.Code128);
settings.AddTypesToRead(BarcodeType.DataMatrix);
settings.AddTypesToRead(BarcodeType.QRCode);
// Scan barcodes from the document.
Barcode[] result = BarcodeReader.ReadBarcodes(settings, bitmap);
if (result.Length > 0)
{
foreach (Barcode barcode in result)
{
Console.WriteLine("Barcode Type: " + barcode.Type.ToString());
Console.WriteLine("Barcode Data: " + barcode.DataString);
}
}
else
Console.WriteLine("[No Barcode Found]");
The following c# source code will scan, read all sdk support barcode types from the document.
String inputFilePath = @"C:\1.jpg";
// Open JPEG file
Bitmap bitmap = new Bitmap(inputFilePath);
// Initial reader's setting
ReaderSettings settings = new ReaderSettings();
// Set target barcode types to All.
settings.AddTypesToRead(BarcodeType.All);
// Scan barcodes from the document.
Barcode[] result = BarcodeReader.ReadBarcodes(settings, bitmap);
if (result.Length > 0)
{
foreach (Barcode barcode in result)
{
Console.WriteLine("Barcode Type: " + barcode.Type.ToString());
Console.WriteLine("Barcode Data: " + barcode.DataString);
}
}
else
Console.WriteLine("[No Barcode Found]");
C#: scan, read QR Code barcodes from an image region
The C# code below will scan, read QR Code datas from an image region.
String inputFilePath = @"C:\1.jpg";
// Open JPEG file
Bitmap bitmap = new Bitmap(inputFilePath);
// Initial reader's setting
ReaderSettings settings = new ReaderSettings();
// Set target barcode type
settings.AddTypesToRead(BarcodeType.QRCode);
// Set scan region: from 10% to 50% of width in horizontal (from left to right)
// and from 0% to 40% of height in vertical (from top to bottom).
settings.RegionOfInterest = new Rectangle(10, 0, 50, 40);
// Scan barcodes from the document.
Barcode[] result = BarcodeReader.ReadBarcodes(settings, bitmap);
if (result.Length > 0)
{
foreach (Barcode barcode in result)
Console.WriteLine("Barcode Data: " + barcode.DataString);
}
else
Console.WriteLine("[No Barcode Found]");
C#: scan, read barcode QR Code from PDF page list
The C# code below will scan, read QR Code datas from Adobe PDF document pages list
String inputFilePath = @"C:\1.pdf";
// Open PDF file
PDFDocument doc = new PDFDocument(inputFilePath);
// Initial reader's setting
ReaderSettings settings = new ReaderSettings();
// Set target barcode type
settings.AddTypesToRead(BarcodeType.QRCode);
// Scan barcodes from the first page.
int pageIndex = 0;
Barcode[] result = BarcodeReader.ReadBarcodes(settings, doc.GetPage(pageIndex));
if (result.Length > 0)
{
foreach (Barcode barcode in result)
Console.WriteLine("Barcode Data: " + barcode.DataString);
}
else
Console.WriteLine("[No Barcode Found]");
C#: scan, read barcode QR Code from tiff document pages list
The C# code below will scan, read QR Code datas from tiff document pages list
String inputFilePath = @"C:\1.tif";
// Open TIFF file
TIFFDocument doc = new TIFFDocument(inputFilePath);
// Initial reader's setting
ReaderSettings settings = new ReaderSettings();
// Set target barcode type
settings.AddTypesToRead(BarcodeType.QRCode);
// Scan barcodes from the first page.
int pageIndex = 0;
Barcode[] result = BarcodeReader.ReadBarcodes(settings, doc.GetPage(pageIndex));
if (result.Length > 0)
{
foreach (Barcode barcode in result)
Console.WriteLine("Barcode Data: " + barcode.DataString);
}
else
Console.WriteLine("[No Barcode Found]");