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的密碼、選擇要掃描的頁面、在Dpi中解析PDF的過程,以及任何需要的額外縮放以改善讀取品質。

關鍵要點

  1. 建立PdfBarcodeReaderOptions
    • 建立PdfBarcodeReaderOptions的實例以設置PDF處理的各種選項:
      • Dpi:設置PDF解析的解析度。 較高的Dpi可以提高條碼檢測的準確性。
      • PageNumbers:指定要掃描的PDF頁面。 這可以客製化以針對特定頁面。
      • Password:如果PDF受到密碼保護,可以使用此選項提供正確的密碼。
      • ScaleToY:這些選項允許調整PDF圖像的比例,以幫助增強條碼檢測的準確性。
  2. 讀取條碼
    • 使用ReadPdfBarcodes方法從PDF文件中讀取和解碼條碼。它使用所指定的選項。
  3. 遍歷和顯示結果
    • 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天試用金鑰
無需信用卡或帳戶建立