IRONSOFTWAREHOME

在IronOCR中減少PDF文件大小

Curtis Chau
Curtis Chau
Updated: 2026年6月29日

如何在IronOCR中減少輸出PDF的文件大小?

IronOCR會自動將檢測為低質量(低於150DPI)的輸入進行放大,以確保準確的讀取結果。

如果檢測到DPI低於150,TargetDPI(預設為225DPI)界定了PDF渲染的DPI。 這與手動設置TargetDPI = 225相同。

要減少輸出文件大小,您可以設置較低的TargetDPI,這將建立較小的PDF。 然而,設置得過低可能會影響OCR性能,因此保持平衡至關重要。

建議的值有96、72、48。

// Example of reducing PDF output file size by lowering the DPI

// Example 1: Reducing DPI to 96
using IronOcr;  // Import IronOCR namespace

var Ocr = new IronTesseract(); // Initialize IronTesseract for OCR operations

using (var Input = new OcrInput()) // Create OCR input object
{
    Input.TargetDPI = 96;    // Set the desired DPI; 96 is used for smaller output size
    Input.AddPdf("example.pdf", "password"); // Add input PDF (with optional password)
    
    var Result = Ocr.Read(Input); // Perform OCR on the input
    Console.WriteLine(Result.Text); // Output recognized text to the console
}

// Example 2: Another way to set DPI
var ocr = new IronTesseract();

using (var ocrInput = new OcrInput()) // Create a new OCR input object
{
    ocrInput.AddPdf("img/Input.pdf", 72); // Add PDF with the specified DPI of 72
    var ocrResult = ocr.Read(ocrInput); // Read and process the PDF

    ocrResult.SaveAsSearchablePdf(@"Output.pdf"); // Save result to a searchable PDF
}

要禁用自動放大功能,請使用TargetDPI = 0。 這將使IronOCR按原樣讀取輸入文件,忽略TargetDPI值。

有關更多資訊,請參閱API:IronOCR API Reference

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

...
閱讀更多

準備開始了嗎?

Nuget Downloads 6,262,020版本:2026.9剛剛發布

立即獲取您的30天試用金鑰
無需信用卡或帳戶建立
Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

OR
bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
預訂您的免費線上演示
Booking Badge

受到全球數百萬工程師的信任

Iron Software的客戶標誌
獲取您的無義務咨詢
填寫下方表格或發送電子郵件至sales@ironsoftware.com
您的詳細資訊將始終保密。
受到全球數百萬工程師的信任
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立