This topic has not yet been rated - Rate this topic

DocumentPaginator Class

Provides an abstract base class that supports creation of multiple-page elements from a single document.

Namespace:  System.Windows.Documents
Assembly:  PresentationCore (in PresentationCore.dll)
public abstract class DocumentPaginator

The DocumentPaginator type exposes the following members.

  Name Description
Protected method DocumentPaginator Initializes a new instance of the DocumentPaginator class.
Top
  Name Description
Public property IsPageCountValid When overridden in a derived class, gets a value indicating whether PageCount is the total number of pages.
Public property PageCount When overridden in a derived class, gets a count of the number of pages currently formatted
Public property PageSize When overridden in a derived class, gets or sets the suggested width and height of each page.
Public property Source When overridden in a derived class, returns the element being paginated.
Top
  Name Description
Public method CancelAsync Cancels a previous GetPageAsync or DynamicDocumentPaginator.GetPageNumberAsync operation.
Public method ComputePageCount Forces a pagination of the content, updates PageCount with the new total, and sets IsPageCountValid to true.
Public method ComputePageCountAsync() Asynchronously, forces a pagination of the content, updates PageCount with the new total, and sets IsPageCountValid to true.
Public method ComputePageCountAsync(Object) Asynchronously, forces a pagination of the content, updates PageCount with the new total, sets IsPageCountValid to true.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetPage When overridden in a derived class, gets the DocumentPage for the specified page number.
Public method GetPageAsync(Int32) Asynchronously returns (through the GetPageCompleted event) the DocumentPage for the specified page number.
Public method GetPageAsync(Int32, Object) Asynchronously returns (through the GetPageCompleted event) the DocumentPage for the specified page number and assigns the specified ID to the asynchronous task.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method OnComputePageCountCompleted Raises the ComputePageCountCompleted event.
Protected method OnGetPageCompleted Raises the GetPageCompleted event.
Protected method OnPagesChanged Raises the PagesChanged event.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Public event ComputePageCountCompleted Occurs when a ComputePageCountAsync operation has finished.
Public event GetPageCompleted Occurs when GetPageAsync has completed.
Public event PagesChanged Occurs when the document content is changed.
Top

If you need automatic background repagination in response to events such as changing the page size of a FlowDocument, then use DynamicDocumentPaginator as your base class.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Using DocumentPaginator with a PrintDialog Class
<FlowDocument Name="flowDocument">
<Paragraph>
The PrintDocument method of PrintDialog Class requires
a DocumentPaginator object to print. Although this
approach is somewhat roundabout, you can obtain an instance
of DocumentPaginator that represents your flow document by
first casting the flow document as an IDocumentPaginatorSource
and then accessing its DocumentPaginator property.
</Paragraph>
<BlockUIContainer FontFamily="Segoe Print">
<Button Content="Print" Click="Button_Click" />
</BlockUIContainer>
<Paragraph>
<Hyperlink NavigateUri="Page1.xaml">Page1.xaml</Hyperlink>
</Paragraph>
</FlowDocument>


Inside of Click event (Button_Click) add the follow code:

private void Button_Click(object sender, RoutedEventArgs e)
{
  PrintDialog pd = new PrintDialog();
  if (pd.ShowDialog() == true)
  {
    DocumentPaginator aDocPage =
      ((IDocumentPaginatorSource)flowDocument).DocumentPaginator;
    aDocPage.PageSize = new Size(pd.PrintableAreaWidth, pd.PrintableAreaHeight);
    pd.PrintDocument(aDocPage, "My Document Paginator");
  }
}


antonio h lopes
2011/02/15