GetFormattedText

GetFormattedText(FormattedTextOptions)

문서에서 서식 있는 텍스트를 추출합니다.

public TextReader GetFormattedText(FormattedTextOptions options)
모수 유형 설명
options FormattedTextOptions 서식이 지정된 텍스트 추출 옵션입니다.

반환 값

의 인스턴스TextReader 추출된 텍스트가 있는 클래스; 없는 서식 있는 텍스트 추출이 지원되지 않는 경우.

비고

더 알아보기:

다음 예는 문서 텍스트를 HTML 텍스트로 추출하는 방법을 보여줍니다.

// Parser 클래스의 인스턴스 생성
using (Parser parser = new Parser(filePath))
{
    // 포맷된 텍스트를 판독기로 추출합니다.
    using (TextReader reader = parser.GetFormattedText(new FormattedTextOptions(FormattedTextMode.Html)))
    {
        // 문서에서 서식 있는 텍스트를 인쇄합니다.
        // 형식화된 텍스트 추출이 지원되지 않는 경우 판독기는 null입니다.
        Console.WriteLine(reader == null ? "Formatted text extraction isn't suppported" : reader.ReadToEnd());
    }
}

또한보십시오


GetFormattedText(int, FormattedTextOptions)

문서 페이지에서 서식 있는 텍스트를 추출합니다.

public TextReader GetFormattedText(int pageIndex, FormattedTextOptions options)
모수 유형 설명
pageIndex Int32 0부터 시작하는 페이지 인덱스입니다.
options FormattedTextOptions 서식이 지정된 텍스트 추출 옵션입니다.

반환 값

의 인스턴스TextReader추출된 텍스트가 있는 클래스; 없는 서식 있는 텍스트 페이지 추출이 지원되지 않는 경우.

비고

더 알아보기:

다음 예제에서는 문서 페이지 텍스트를 Markdown 텍스트로 추출하는 방법을 보여줍니다.

// Parser 클래스의 인스턴스 생성
using (Parser parser = new Parser(filePath))
{
    // 문서가 서식 있는 텍스트 추출을 지원하는지 확인
    if (!parser.Features.FormattedText)
    {
        Console.WriteLine("Document isn't supports formatted text extraction.");
        return;
    }
    
    // 문서 정보 가져오기
    IDocumentInfo documentInfo = parser.GetDocumentInfo();
    // 문서에 페이지가 있는지 확인
    if (documentInfo.PageCount == 0)
    {
        Console.WriteLine("Document hasn't pages.");
        return;
    }
    
    // 페이지를 반복
    for (int p = 0; p<documentInfo.PageCount; p++)
    {
        // 페이지 번호 출력 
        Console.WriteLine(string.Format("Page {0}/{1}", p + 1, documentInfo.PageCount));
        // 포맷된 텍스트를 판독기로 추출합니다.
        using (TextReader reader = parser.GetFormattedText(p, new FormattedTextOptions(FormattedTextMode.Markdown)))
        {
            // 문서에서 서식 있는 텍스트를 인쇄합니다.
            // 이전에 형식화된 텍스트 추출 기능 지원을 확인했으므로 null 검사를 무시합니다.
            Console.WriteLine(reader.ReadToEnd());
        }
    }
}

또한보십시오