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
$vbLabelText   $csharpLabel

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.

WarningHigher DPI values increase processing time, so raise the resolution only as far as detection requires.

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.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More
Ready to Get Started?
Nuget Downloads 2,306,850 | Version: 2026.7 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast? PM > Install-Package BarCode
run a sample watch your string become a barcode.