IronOCR 故障排除 與 PDFs 的內容區域和裁剪區域 使用IronOCR處理作物區域和矩形 Curtis Chau 更新:2025年6月1日 下載 IronOCR NuGet 下載 DLL 下載 Windows 安裝程式 開始免費試用 LLM副本 LLM副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English 如何使用IronOCR設定 PDF 的內容區域? 內容區域和 PDF OcrInput.LoadPdf 和 LoadPdfPage 方法都可以選擇新增ContentArea 。 問題是-PDF 檔案的大小不是以像素為單位的,但內容區域通常是以像素為單位的,我該如何知道我的內容區域有多大? 選項 1 OcrInput.TargetDPI 預設值為 225 - 這決定了 PDF 影像的大小(以像素為單位)。 IronOCR會看到這則訊息。 方案二(理想使用場景) 請在 PDF 範本中使用 OcrInput.LoadPdf()。 使用 OcrInput.GetPages() 取得輸入框的寬度和高度。 使用 OcrInput.GetPages().First().ToBitmap() 取得 OCR 引擎將讀取的確切影像。 現在您可以測量匯出影像中內容區域的像素大小。 目標座標可用於特定的 OCR 區域(請參閱最終結果)。 取得您的資訊: using System.Linq; // Needed for First() using IronOcr; var ocr = new IronTesseract(); using (var input = new OcrInput()) { // Load the PDF document input.LoadPdf("example.pdf"); // Save the first page as a bitmap to measure it input.GetPages().First().ToBitmap().SaveAs("measure-me.bmp"); // Get the dimensions of the first page var width = input.GetPages().First().Width; var height = input.GetPages().First().Height; // Optionally, output the dimensions to understand the scale Console.WriteLine($"Width: {width}px, Height: {height}px"); } using System.Linq; // Needed for First() using IronOcr; var ocr = new IronTesseract(); using (var input = new OcrInput()) { // Load the PDF document input.LoadPdf("example.pdf"); // Save the first page as a bitmap to measure it input.GetPages().First().ToBitmap().SaveAs("measure-me.bmp"); // Get the dimensions of the first page var width = input.GetPages().First().Width; var height = input.GetPages().First().Height; // Optionally, output the dimensions to understand the scale Console.WriteLine($"Width: {width}px, Height: {height}px"); } $vbLabelText $csharpLabel 最終結果: using IronOcr; using IronSoftware.Drawing; // Needed for Rectangle var ocr = new IronTesseract(); using (var input = new OcrInput()) { // Define the content area rectangle with specific pixel coordinates var contentArea = new Rectangle { X = 215, Y = 1250, Height = 280, Width = 1335 }; //<-- the area you want in px // Load the specific content area of the PDF input.LoadPdf("example.pdf", contentArea: contentArea); // Perform OCR on the defined content area var result = ocr.Read(input); // Optionally, print the OCR result Console.WriteLine(result.Text); } using IronOcr; using IronSoftware.Drawing; // Needed for Rectangle var ocr = new IronTesseract(); using (var input = new OcrInput()) { // Define the content area rectangle with specific pixel coordinates var contentArea = new Rectangle { X = 215, Y = 1250, Height = 280, Width = 1335 }; //<-- the area you want in px // Load the specific content area of the PDF input.LoadPdf("example.pdf", contentArea: contentArea); // Perform OCR on the defined content area var result = ocr.Read(input); // Optionally, print the OCR result Console.WriteLine(result.Text); } $vbLabelText $csharpLabel API 參考: OcrInput | OcrInput.Page Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 5,556,263 | 版本: 2026.3 剛剛發布 開始免費試用 免費 NuGet 下載 總下載量:5,556,263 查看許可證 還在捲動嗎? 想要快速證明? PM > Install-Package IronOcr 執行範例 觀看您的圖片變成可搜尋的文字。 免費 NuGet 下載 總下載量:5,556,263 查看許可證