This is a migrated thread and some comments may be shown as answers.

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

1 Answer 303 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
GJ
Top achievements
Rank 1
GJ asked on 16 Nov 2016, 07:54 AM

Hi

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?

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 16 Nov 2016, 01:25 PM
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: 
this.radRichTextEditor1.Document.CaretPosition.MoveToFirstPositionOnNextPage();
this.radRichTextEditor1.Document.CaretPosition.MoveToLastPositionOnPreviousPage();

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.

Regards,
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.
Tags
RichTextEditor
Asked by
GJ
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or