How can i get total number pages from a loaded docx document.

2 posts, 0 answers
  1. GJ
    GJ avatar
    5 posts
    Member since:
    Aug 2015

    Posted 16 Nov 2016 Link to this post


    I'm loading a docx document to a RichTextEditor and I need the total number pages because the user need to move around the document with external buttons (page up, page down, fit, ...).

    How can i get Total pages? What is the best way to move around pages and let current page fit at top of control?

  2. Hristo
    Hristo avatar
    1508 posts

    Posted 16 Nov 2016 Link to this post

    Hello GJ,

    Thank you for writing.

    You can navigate to the next and previous pages by using the CaretPosition object and calling the MoveToFirstPositionOnNextPage and MoveToLastPositionOnPreviousPage methods respectively: 

    The count of the total pages can be retrieved accessing the PageNumber property of the last SectionLayoutBox. Please see below:  
    SectionLayoutBox lastSectionLayoutBox = (SectionLayoutBox)this.radRichTextEditor1.Document.DocumentLayoutBox.ChildLayoutBoxes.Last;
    int pagesCount = lastSectionLayoutBox.PageNumber;

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Hristo Merdjanov
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top