IronOCR 사용한 작물 영역 및 사각형

Curtis Chau
Curtis Chau
Updated: 2026년 6월 29일

IronOCR 사용하여 PDF에 콘텐츠 영역을 설정하는 방법은 무엇인가요?

콘텐츠 영역 및 PDF

OcrInput.LoadPdf 및 LoadPdfPage 메서드 모두에 ContentArea를 추가할 수 있는 옵션이 있습니다.

질문은 다음과 같습니다. PDF 파일의 크기는 픽셀 단위로 표시되지 않지만, 콘텐츠 영역은 일반적으로 픽셀 단위로 측정되는데, 콘텐츠 영역의 크기를 어떻게 알 수 있을까요?

옵션 1

OcrInput.TargetDPI 기본값은 225로, 이는 픽셀 단위의 PDF 이미지 크기를 결정합니다. 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 IronOcr;
using IronSoftware.Drawing; // Needed for Rectangle
using System;

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);
}

API 참조: OcrInput | OcrInput.페이지

커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

더 읽어보기

시작할 준비 되셨나요?

Nuget Downloads 6,357,159버전:2026.11방금 출시