IRONSOFTWAREHOME
设置PDF条码阅读器选项
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
设置PDF条码阅读器选项

设置PDF条码阅读器选项

IronBarcode在PdfBarcodeReaderOptions类中有多种选项以支持专门针对PDF的自定义和优化读取。 这将处理PDF密码,选择要扫描的页面,解析PDF的Dpi,以及任何需要的额外缩放以提高读取质量。

关键点

  1. 创建PdfBarcodeReaderOptions
  • 创建一个PdfBarcodeReaderOptions实例以设置PDF处理的各种选项:
  • Dpi:设置PDF解析的分辨率。 较高的Dpi可以提高条形码检测的准确性。
  • PageNumbers:指定应扫描的PDF页面。 这可以自定义以定位特定页面。
  • Password:如果PDF受密码保护,可以使用此选项提供正确的密码。
  • ScaleToY:这些选项可调整PDF图像的比例,以帮助提高条形码检测的准确性。
  1. 读取条码:
  • 使用ReadPdfBarcodes方法从PDF文件中读取和解码条形码。它利用指定的选项。
  1. 迭代和显示结果:
  • Value
    • 这确保从指定页面检测到的所有条码都被输出,以便验证或进一步处理。
学习如何使用 C# 从 PDF 中读取条形码
在 GitHub 上查看

准备开始了吗?

Nuget Downloads 2,422,100版本:2026.9刚刚发布

Key in blue circle

立即获取免费的 30 天试用版密钥

Your trial license will be sent to your email address

无任何限制。100% 解锁。无需信用卡。

bullet_checked无需信用卡或创建账户无任何限制。100% 解锁。无需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
预约您的免费现场演示
Booking Badge

深受全球数百万工程师信赖

Iron Software 的客户徽标
获取您的无义务咨询
填写下面的表格或通过sales@ironsoftware.com
您的资料将始终保密。
深受全球数百万工程师信赖
Iron Software 的客户徽标
立即获取您的免费30 天试用密钥
无需信用卡或创建账户