How To Set Fault Tolerance

by Hairil Hasyimi Bin Omar

What is Fault Tolerance

Fault tolerance is the ability of a barcode to retain its readability, even in the presence of visual damage and errors on the barcode. These damages can arise from various factors such as printing imperfections, smudges, scratches, or variations in scanning conditions. Fault tolerance is one of the major factors for a user to determine which type of barcode encoding is suitable to use.

In general, 2D barcodes has higher fault tolerance compared to 1D barcodes. This is due to factors listed below:

  • Data Capacity: 2D barcodes can store significantly more data than 1D barcodes due to ability to encode data both horizontally and vertically, which includes alphanumerics, binary data, images, and more.
  • Error Correction: 2D barcodes have sophisticated error correction algorithms, which enable the barcode scanner to detect and correct errors in the data, even if parts of the barcode are damaged or obscured.
  • Redundancy: 2D barcodes have multiple layers of data encoding, which helps in extracting information from the remaining intact sections when the barcode is damaged.
  • Compactness: 2D barcodes are suitable for placing on limited spaces due to its compact shape.
  • Flexibility: 2D barcodes can be scanned from various angles and orientations.

C# NuGet Library for

Install with NuGet

Install-Package BarCode

Download DLL

Download DLL

Manually install into your project

Set Fault Tolerance to QR Codes Example

2D barcodes, such as QRCode, DataMatrix, PDF417, and Aztec, feature Error Correction, ensuring they remain readable even when partially damaged. IronBarcode provides the capability to fine-tune this error correction level specifically for QR codes.

You can control the Fault Tolerance level by adjusting the QrErrorCorrection parameter in the QRCodeWriter.CreateQrCode method. Four levels of error correction are available:

  • Highest: 30% error correction
  • High: 25% error correction
  • Medium: 15% error correction
  • Low: 7% error correction

It's worth noting that higher error correction levels result in more complex QR code images. Therefore, users will need to find a balance between visual clarity and fault tolerance when generating QR codes.

using IronBarCode;

GeneratedBarcode mediumCorrection = QRCodeWriter.CreateQrCode("", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium);
Imports IronBarCode

Private mediumCorrection As GeneratedBarcode = QRCodeWriter.CreateQrCode("", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium)
VB   C#

With IronBarcode, it only takes 2 lines of code to produce a QR code with high fault tolerance. Simply invoke the QRCodeWriter.CreateQrCode method and specify parameters such as value, size, ErrorCorrectionLevel, and QR code version. To set the error correction level, use the QRCodeWriter.QrErrorCorrectionLevel enum and choose the desired level. The method returns a GeneratedBarcode object for further use or image saving.

Error Correction Comparison

Below is a sample set of QR Code images, each representing the same value but with varying levels of error correction. As evident, higher levels of error correction result in more complex QR code images, which in turn offer greater fault tolerance.

Highest Error Correction
High Error Correction
Medium Error Correction
Low Error Correction