IronOCR 疑難排解 在 IronOcr 中縮小輸出 PDF 的檔案大小 在 IronOCR 中減少 PDF 檔案大小 Curtis Chau 更新:6月 1, 2025 下載 IronOCR NuGet 下載 DLL 下載 Windows 安裝程式 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在雙子座打開 請向 Gemini 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English 如何減少 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 } // 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 } ' Example of reducing PDF output file size by lowering the DPI ' Example 1: Reducing DPI to 96 Imports IronOcr ' Import IronOCR namespace Private Ocr = New IronTesseract() ' Initialize IronTesseract for OCR operations Using 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) Dim Result = Ocr.Read(Input) ' Perform OCR on the input Console.WriteLine(Result.Text) ' Output recognized text to the console End Using ' Example 2: Another way to set DPI Dim ocr = New IronTesseract() Using ocrInput As New OcrInput() ' Create a new OCR input object ocrInput.AddPdf("img/Input.pdf", 72) ' Add PDF with the specified DPI of 72 Dim ocrResult = ocr.Read(ocrInput) ' Read and process the PDF ocrResult.SaveAsSearchablePdf("Output.pdf") ' Save result to a searchable PDF End Using $vbLabelText $csharpLabel 若要停用自動放大,請使用TargetDPI = 0 。 這將使 IronOCR 以原樣讀取輸入文件,忽略 TargetDPI 值。 更多資訊請參閱 API: IronOCR API 參考 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 5,167,857 | Version: 2025.11 剛發表 免費下載 NuGet 下載總數:5,167,857 檢視授權