IRONSOFTWAREHOME
Set PDF Barcode Reader Options
using IronBarCode;

PdfBarcodeReaderOptions myPdfOptionsExample = new PdfBarcodeReaderOptions()
{
    // The password string to open the PDF if there is one
    Password = "password123",

    // Pages of the PDF you want to scan
    PageNumbers = new[] { 1, 3 },

    // By default, all barcode formats are scanned for
    // Specifying a subset of barcode types to search for would improve performance
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,

    // The DPI (dots per inch) to render each barcode image for reading
    DPI = 72,

    // The scaling factor to scale the width and height when converting the PDF to image
    // Default is 3.5 for both dimensions
    Scale = 4
};

// Read the pdf with the options applied
var results = BarcodeReader.ReadPdf("barcode.pdf", myPdfOptionsExample);
Imports IronBarCode

Dim myPdfOptionsExample As New PdfBarcodeReaderOptions() With {
    .Password = "password123",
    .PageNumbers = {1, 3},
    .ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
    .DPI = 72,
    .Scale = 4
}

' Read the pdf with the options applied
Dim results = BarcodeReader.ReadPdf("barcode.pdf", myPdfOptionsExample)
NuGet Download
PM > Install-Package BarCode
Set PDF Barcode Reader Options

Set PDF Barcode Reader Options

IronBarcode has a variety of options in the PdfBarcodeReaderOptions class to support customized and optimized reads for PDFs specifically. This will handle PDF passwords, choose which pages to scan, the DPI to parse the PDF in, and any additional scaling needed to improve the read quality.

Key Points

  1. Creating PdfBarcodeReaderOptions:
    • An instance of PdfBarcodeReaderOptions is created to set various options for PDF processing:
      • DPI: Sets the resolution for PDF parsing. Higher DPI can improve barcode detection accuracy.
      • PageNumbers: Specifies the PDF pages that should be scanned. This can be customized to target specific pages.
      • Password: If the PDF is password-protected, the correct password can be provided using this option.
      • Scale: This option (default 3.5) allows adjusting the scale of the PDF image to help in enhancing the barcode detection accuracy.
  2. Reading Barcodes:
    • The BarcodeReader.ReadPdf method is used to read and decode barcodes from the PDF file. It utilizes the options specified.
  3. Iterating and Displaying Results:
    • A foreach loop iterates over the barcode results, displaying each barcode's Type and Value on the console.
    • This ensures that all detected barcodes from the specified pages are outputted for verification or further processing.
Learn how to read barcodes from PDFs with C#
View on GitHub

Ready to Get Started?

Nuget Downloads 2,422,100Version:2026.9just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required