How To Set Fault Tolerance
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.
How to Set Fault Tolerance
- Download the C# library to set fault tolerance on barcodes
- Use the QRCodeWriter class to generate a QR code
- Modify the QrErrorCorrection parameter to adjust the error correction level
- Compare the QR codes generated visually at four different error correction levels
- Examine the outputted QR codes

Install with NuGet
Install-Package BarCode
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.
:path=/static-assets/barcode/content-code-examples/how-to/set-fault-tolerance.cs
using IronBarCode;
GeneratedBarcode mediumCorrection = QRCodeWriter.CreateQrCode("https://ironsoftware.com/csharp/barcode/", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium);
mediumCorrection.SaveAsPng("mediumCorrection.png");
Imports IronBarCode
Private mediumCorrection As GeneratedBarcode = QRCodeWriter.CreateQrCode("https://ironsoftware.com/csharp/barcode/", 500, QRCodeWriter.QrErrorCorrectionLevel.Medium)
mediumCorrection.SaveAsPng("mediumCorrection.png")
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