IronOCR トラブルシューティング PDFのコンテンツ領域と作物領域 Crop Regions and Rectangles with IronOCR Curtis Chau 更新日:6月 1, 2025 Download IronOCR NuGet Download テキストの検索と置換 テキストと画像のスタンプ Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article 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です。 IronOCRはこれを読みます。 オプション2(理想的な使用例) 1.PDFテンプレートでOcrInput.LoadPdf()を使用してください。 2.入力の幅と高さを取得するには、OcrInput.GetPages()を使用してください。 3.OCR エンジンが読み取る正確な画像を取得するには、OcrInput.GetPages().First().ToBitmap()を使用してください。 4.エクスポートした画像から、ContentAreasをピクセル単位で測定できるようになりました。 5.対象となる座標は、特定の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"); } Imports System.Linq ' Needed for First() Imports IronOcr Private ocr = New IronTesseract() Using 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 Dim width = input.GetPages().First().Width Dim height = input.GetPages().First().Height ' Optionally, output the dimensions to understand the scale Console.WriteLine($"Width: {width}px, Height: {height}px") End Using $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); } Imports IronOcr Imports IronSoftware.Drawing ' Needed for Rectangle Private ocr = New IronTesseract() Using input = New OcrInput() ' Define the content area rectangle with specific pixel coordinates Dim contentArea = New Rectangle With { .X = 215, .Y = 1250, .Height = 280, .Width = 1335 } ' Load the specific content area of the PDF input.LoadPdf("example.pdf", contentArea:= contentArea) ' Perform OCR on the defined content area Dim result = ocr.Read(input) ' Optionally, print the OCR result Console.WriteLine(result.Text) End Using $vbLabelText $csharpLabel APIリファレンス:IronOCRInput。|IronOCRInput.Page。 Curtis Chau 今すぐエンジニアリングチームとチャット テクニカルライター Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。 準備はいいですか? Nuget ダウンロード 5,044,537 | バージョン: 2025.11 ただ今リリースされました 試用ライセンスキーがメールで送信されました。 総ダウンロード数: 5,044,537 ライセンスを見る