Barcode Not Read from PDF
Barcodes embedded in a PDF page can return no result when read with the default reader settings. The default render resolution is often too low to keep a small or dense barcode legible, the scan skips machine-learning detection, and the reader wastes effort searching every supported symbology instead of the ones actually on the page.
Solution
Configure PdfBarcodeReaderOptions before reading. Raise the render DPI, switch to machine-learning detection, and restrict the search to the barcode types you expect, then read the PDF.
using IronBarCode;
var options = new PdfBarcodeReaderOptions
{
// Render each page at a higher resolution so small or dense barcodes stay legible
DPI = 400,
// Use machine-learning detection and reading
ScanMode = BarcodeScanMode.MachineLearningScan,
// Restrict the search to the symbologies that are actually present
ExpectBarcodeTypes = BarcodeEncoding.ITF | BarcodeEncoding.Code128
};
BarcodeResults results = BarcodeReader.ReadPdf("input.pdf", options);
foreach (var pageResult in results)
{
string value = pageResult.Value;
// use value
}
using IronBarCode;
var options = new PdfBarcodeReaderOptions
{
// Render each page at a higher resolution so small or dense barcodes stay legible
DPI = 400,
// Use machine-learning detection and reading
ScanMode = BarcodeScanMode.MachineLearningScan,
// Restrict the search to the symbologies that are actually present
ExpectBarcodeTypes = BarcodeEncoding.ITF | BarcodeEncoding.Code128
};
BarcodeResults results = BarcodeReader.ReadPdf("input.pdf", options);
foreach (var pageResult in results)
{
string value = pageResult.Value;
// use value
}
Imports IronBarCode
Dim options As New PdfBarcodeReaderOptions With {
.DPI = 400,
.ScanMode = BarcodeScanMode.MachineLearningScan,
.ExpectBarcodeTypes = BarcodeEncoding.ITF Or BarcodeEncoding.Code128
}
Dim results As BarcodeResults = BarcodeReader.ReadPdf("input.pdf", options)
For Each pageResult In results
Dim value As String = pageResult.Value
' use value
Next
BarcodeScanMode.MachineLearningScan applies ML-based detection rather than the default scan, which handles imperfect or low-contrast barcodes far better.
1. Increase the DPI for small or dense barcodes
Raise DPI when barcodes stay undetected. A higher value renders each page at greater resolution and gives the reader more detail to lock onto. Bump it incrementally, for example to 600, and re-test.
2. Name the expected symbologies
Set ExpectBarcodeTypes to only the encodings you expect, combining them with the bitwise OR operator, for example BarcodeEncoding.ITF | BarcodeEncoding.Code128. Naming the expected types improves both accuracy and performance over scanning for every supported format.

