Back to Devexpress

DocumentLayout.GetFormattedPageCount() Method

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-layout-dot-documentlayout-7b653a5d.md

latest5.3 KB
Original Source

DocumentLayout.GetFormattedPageCount() Method

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

Declaration

csharp
public int GetFormattedPageCount()
vb
Public Function GetFormattedPageCount As Integer

Returns

TypeDescription
Int32

An integer that is the number of pages in the document layout.

|

Remarks

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.

winforms-richedit-layout-api-practical-usage/CS/WindowsFormsApplication1/DocumentLayoutHelper/PageLayoutHelper.cs#L15

csharp
int currentPageIndex = currentDocumentLayout.GetPageIndex(currentPage);
int totalPageCount = currentDocumentLayout.GetFormattedPageCount();

winforms-richedit-layout-api/CS/Form1.cs#L25

csharp
{
    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

csharp
MyLayoutVisitor visitor = new MyLayoutVisitor(richEditControl1.Document);
int pageCount = richEditControl1.DocumentLayout.GetFormattedPageCount();

winforms-richedit-layout-api-practical-usage/VB/WindowsFormsApplication1/DocumentLayoutHelper/PageLayoutHelper.vb#L18

vb
Dim currentPageIndex As Integer = currentDocumentLayout.GetPageIndex(currentPage)
Dim totalPageCount As Integer = currentDocumentLayout.GetFormattedPageCount()

winforms-richedit-layout-api/VB/Form1.vb#L21

vb
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

vb
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

DocumentLayout Class

DocumentLayout Members

DevExpress.XtraRichEdit.API.Layout Namespace