ParserGetTextAreas Method (Int32)
Extracts text areas from the document page.

Namespace: GroupDocs.Parser
Assembly: GroupDocs.Parser (in GroupDocs.Parser.dll) Version: 20.8.0
Syntax
public IEnumerable<PageTextArea> GetTextAreas(
	int pageIndex
)

Parameters

pageIndex
Type: SystemInt32
The zero-based page index.

Return Value

Type: IEnumerablePageTextArea
A collection of PageTextArea objects; null if text areas extraction isn't supported.
Remarks
Examples

To extract text areas from a document page the following method is used:

C#
// Create an instance of Parser class
using(Parser parser = new Parser(filePath))
{
    // Check if the document supports text areas extraction
    if(!parser.Features.TextAreas)
    {
        Console.WriteLine("Document isn't supports text areas extraction.");
        return;
    }

    // Get the document info
    IDocumentInfo documentInfo = parser.GetDocumentInfo();
    // Check if the document has pages
    if(documentInfo.PageCount == 0)
    {
        Console.WriteLine("Document hasn't pages.");
        return;
    }

    // Iterate over pages
    for(int pageIndex = 0; pageIndex<documentInfo.PageCount; pageIndex++)
    {
        // Print a page number 
        Console.WriteLine(string.Format("Page {0}/{1}", pageIndex + 1, documentInfo.PageCount));

        // Iterate over page text areas
        // We ignore null-checking as we have checked text areas extraction feature support earlier
        foreach(PageTextArea a in parser.GetTextAreas(pageIndex))
        {
            // Print a rectangle and text area value:
            Console.WriteLine(string.Format("R: {0}, Text: {1}", a.Rectangle, a.Text));
        }
    }
}
See Also