Guide for C#
Core Document Formats
Additional Features
QR Code

C# Imaging - Read 2D QR Code in C#.NET

Sample C# Code to Decode QR Code from Document Image

Visual C#
Home > .NET Imaging SDK > C# > Read QR Code on Doc Image
If this is your first time to use our DocImageSDK, we strongly suggest you reading How to Start first!

C# Imaging - QR Code Reading Control
C#.NET BarcodeRead Add-on from RasterEdge DocImage SDK for .NET is a reliable, accurate & fast barcode detecting and reading control, designed specifically for .NET class applications (including ASP.NET web service and Windows application). This barcode decoding control can read QR Code barcode from scanned image files (including tiff, png, jpeg, png and bmp) and common documents (including PDF, MS Word, Excel & PowerPoint).
Besides, its ability to scan QR Code from a full page or certain specified region using C# code makes it extremely easy for users to optimize the barcode reading rate based on different applications.
QR Code, short for Quick Response Code, has become one of the most commonly used 2D barcode types in the world based on its huge information storage, high-level error correction level and square barcode pattern.
As QR Code has a wide valid data scope, thus, people often encode a website link into QR Code. Then one can easily visit this website by just scanning the QR code barcode, instead of entering the url in the web browser. Therefore, QR Code has been widely used in the marketing and advertising field as a promotion tool.
This QR Code detecting and reading tutorial for C#.NET document imaging application is divided into three parts:
  • C# imaging - QR Code reading & detecting from image file using C#.NET
  • C# imaging - QR Code reading & decoding from PDF document using C#.NET
  • C# imaging - QR Code scanning & detecting from Word document using C#.NET
  • C# imaging - QR Code detecting and decoding from Excel document
  • C# imaging - QR Code scanning and reading from PPTX document slide
C#.NET QR Code Reader Control Features
  • Mature QR Code barcode reading library for C#.NET imaging project with reasonable licensing
  • Compatible with .NET Framework 2.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
If you want to know more detailed information on barcode reading & recognition from PDF document using C#.NET, please follow the link to read step-to-step tutorial and sample C# code.
Read QR Code from Scanned Image File 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 tiff, png, jpeg, bmp and gif. The sample C# codes below can help you detect all QR Code barcodes from png and tiff image files and return the decoding values to data string.
// register all dll references to the project
// this code need only be invoked at the beginning of your prgram
WorkRegistry.Reset();

// load an image containing barcode image on it
REImage reImage = new REImage(@"c:\barcodePDF.png");

// set reader setting
ReaderSettings setting = new ReaderSettings();

// read QR Code
setting.AddTypesToRead(BarcodeType.QRCode);

// you can set the region of interest in the image, and the number is in percentage
setting.RegionOfInterest = new System.Drawing.Rectangle(0, 0, 50, 50);

// read barcode form image
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, reImage);

foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);
// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}

Decode QR Code from TIFF Image File

public static void ReadBarcodeFromTIFF()
{
// register all dll references to your project
// this code need only be invoked at the beginning of your prgram
WorkRegistry.Reset();

// load TIFF document
TIFFDocument doc = new TIFFDocument(@"c:\sample.tiff");

// get the page you want to scan
BasePage page = doc.GetPage(0);

// set reader setting
ReaderSettings setting = new ReaderSettings();

// set type to read
setting.AddTypesToRead(BarcodeType.QRCode);

// read barcode from TIFF page
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, page);

foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);

// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}
}
Read QR Code from PDF File Using C# Code
This C#.NET barcode scanning control can also detect all the QR Code barcodes automatically from scanned PDF document file. Besides, by default, the barcode reader and scanner will detect all the QR Code barcodes from the whole PDF page with five algorithms.
// register all dll references to your project
// this code need only be invoked at the beginning of your prgram
WorkRegistry.Reset();

// load PDF document
PDFDocument doc = new PDFDocument(@"c:\REImageBarcoded.pdf");

// get the page you want to scan
BasePage page = doc.GetPage(0);

// set reader setting
ReaderSettings setting = new ReaderSettings();

// set type to read
setting.AddTypesToRead(BarcodeType.QRCode);

// read barcode from PDF page
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, page);

foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);

// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}
Recognize QR Code from Word Document 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.
// register all dll references to your project
// this code need only be invoked at the beginning of your prgram
WorkRegistry.Reset();

// load Word document
DOCXDocument doc = new DOCXDocument(@"c:\REImageBarcoded.docx");

// get the page you want to scan
BasePage page = doc.GetPage(0);

// set reader setting
ReaderSettings setting = new ReaderSettings();

// set type to read
setting.AddTypesToRead(BarcodeType.QRCode);

// read barcode from Word page
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, page);

foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);

// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}
Scan QR Code on a Certain Excel Page in C#.NET
Apart from MS Word document, users also are supposed to use RasterEdge .NET Imaging Barcode Reading control to decode QR Code on a certain Excel document page with folloiwng C# sample code.
// register all dll references to your project
// this code need only be invoked at the beginning of your prgram
WorkRegistry.Reset();

// load Excel document
XLSXDocument doc = new XLSXDocument(@"c:\REImageBarcoded.xlsx");

// get the page you want to scan
BasePage page = doc.GetPage(0);

// set reader setting
ReaderSettings setting = new ReaderSettings();

// set type to read
setting.AddTypesToRead(BarcodeType.QRCode);

// read barcode from Excel sheet
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, page);

foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);

// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}
Recognize QR Code from PPTX Document in C#.NET
Users can detect and scan QR Code barcode from MS PowerPoint slide/page in high performance by combining RasterEdge .NET Imaging Barcode Reader and MS PPTX Document dll. Please see following demo code in C# class for detailed guide.
// register all dll references to your project
// this code need only be invoked at the beginning of your prgram
WorkRegistry.Reset();

// load PowerPoint document
PPTXDocument doc = new PPTXDocument(@"c:\REImageBarcoded.pptx");

// get the page you want to scan
BasePage page = doc.GetPage(0);

// set reader setting
ReaderSettings setting = new ReaderSettings();

// set type to read
setting.AddTypesToRead(BarcodeType.QRCode);

// read barcode from PowerPoint slide
Barcode[] barcodes = BarcodeReader.ReadBarcodes(setting, page);

foreach (Barcode barcode in barcodes)
{
// print the loaction of barcode on image
Console.WriteLine(barcode.BoundingRectangle.X + " " + barcode.BoundingRectangle.Y);

// output barcode data onto screen
Console.WriteLine(barcode.DataString);
}


Recommend this to Google+