officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-layout-dot-documentlayout-7b653a5d.md
Obtains a number of pages for which layout has been already calculated.
Namespace : DevExpress.XtraRichEdit.API.Layout
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
public int GetFormattedPageCount()
Public Function GetFormattedPageCount As Integer
| Type | Description |
|---|---|
| Int32 |
An integer that is the number of pages in the document layout.
|
Use the GetFormattedPageCount value to get the actual number of formatted pages. The pages are formatted asynchronously.
Handle the DocumentLayout.DocumentFormatted event and call the GetFormattedPageCount method to retrieve a more accurate number of pages.
The document layout in RichEditDocumentServer is calculated on demand (the RichEditDocumentServer.LayoutCalculationMode property is set to Manual), so the GetFormattedPageCount method returns 0 after the document is loaded.
You can use the DocumentLayout.GetPageCount() method to retrieve the number of pages in the document.
The following code snippets (auto-collected from DevExpress Examples) contain references to the GetFormattedPageCount() method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
int currentPageIndex = currentDocumentLayout.GetPageIndex(currentPage);
int totalPageCount = currentDocumentLayout.GetFormattedPageCount();
winforms-richedit-layout-api/CS/Form1.cs#L25
{
int pageCount = richEditControl1.DocumentLayout.GetFormattedPageCount();
for (int i = 0; i < pageCount; i++)
winforms-richedit-enable-line-numbering-and-count-document-rows/CS/LineNumberingExample/Form1.cs#L76
MyLayoutVisitor visitor = new MyLayoutVisitor(richEditControl1.Document);
int pageCount = richEditControl1.DocumentLayout.GetFormattedPageCount();
Dim currentPageIndex As Integer = currentDocumentLayout.GetPageIndex(currentPage)
Dim totalPageCount As Integer = currentDocumentLayout.GetFormattedPageCount()
winforms-richedit-layout-api/VB/Form1.vb#L21
richEditControl1.BeginInvoke(New Action(Sub()
Dim pageCount As Integer = richEditControl1.DocumentLayout.GetFormattedPageCount()
For i As Integer = 0 To pageCount - 1
winforms-richedit-enable-line-numbering-and-count-document-rows/VB/LineNumberingExample/Form1.vb#L72
Dim visitor As MyLayoutVisitor = New MyLayoutVisitor(richEditControl1.Document)
Dim pageCount As Integer = richEditControl1.DocumentLayout.GetFormattedPageCount()
For i As Integer = 0 To pageCount - 1
See Also