스탬프에서 텍스트 추출하기 C#

스탬프 주석에서 텍스트 추출하기

Aspose.PDF for NET를 사용하면 스탬프 주석에서 텍스트를 추출할 수 있습니다. PDF에서 스탬프 주석의 텍스트를 추출하기 위해 다음 단계를 사용할 수 있습니다.

  1. Document 클래스 객체를 생성합니다.
  2. 페이지의 주석 목록에서 원하는 Annotation을 가져옵니다.
  3. TextAbsorber 클래스의 새 객체를 정의합니다.
  4. TextAbsorber의 방문 메서드를 사용하여 텍스트를 가져옵니다.

다음 코드 스니펫은 Aspose.PDF.Drawing 라이브러리와 함께 작동합니다.

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void ExtractText()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Text();

    // Open PDF document
    using (var document = new Aspose.Pdf.Document(dataDir + "ExtractStampText.pdf"))
    {
        Aspose.Pdf.Annotations.Annotation item = document.Pages[1].Annotations[1];
        if (item is Aspose.Pdf.Annotations.StampAnnotation annot)
        {
            var absorber = new Aspose.Pdf.Text.TextAbsorber();
            Aspose.Pdf.XForm appearance = annot.Appearance["N"];
            absorber.Visit(appearance);
            Console.WriteLine(absorber.Text);
        }
    }
}