Page ContentI have just found this code snippet that was provided by our support department to help a user to get a text rectangle of a specific page.

Using TX Text Control's Page class, you can get the page bounds and the text bounds. This, however, is a rectangle of possible text on a page and not the text that has been added to the page. Thankfully, getting the value we want is pretty easy.

The following function returns the actual text of a specific page:

// [C#]
private Rectangle GetPageContentRect(int Page)
    Graphics g = textControl1.CreateGraphics();
    int dpiX = (int)(1440 / g.DpiX);

    TXTextControl.Page page = textControl1.GetPages()[Page];
    TXTextControl.Line lastLine = textControl1.Lines.GetItem(page.Start +
                                    page.Length - 2);

    Rectangle rRect = new Rectangle(page.TextBounds.X / dpiX,
                                    page.TextBounds.Y / dpiX,
                                    page.TextBounds.Width / dpiX,
                                    lastLine.TextBounds.Bottom / dpiX -
                                        page.TextBounds.Top / dpiX);

    return rRect;