Export (0) Print
Expand All

AnnotationDocumentPaginator Class

Provides a DocumentPaginator for printing a document together with its associated annotations.

System.Object
  System.Windows.Documents.DocumentPaginator
    System.Windows.Annotations.AnnotationDocumentPaginator

Namespace:  System.Windows.Annotations
Assembly:  PresentationFramework (in PresentationFramework.dll)

public sealed class AnnotationDocumentPaginator : DocumentPaginator

The AnnotationDocumentPaginator type exposes the following members.

  NameDescription
Public methodAnnotationDocumentPaginator(DocumentPaginator, Stream)Initializes a new instance of the AnnotationDocumentPaginator class based on a specified DocumentPaginator and annotation storage Stream.
Public methodAnnotationDocumentPaginator(DocumentPaginator, AnnotationStore)Initializes a new instance of the AnnotationDocumentPaginator class based on a specified DocumentPaginator and AnnotationStore.
Public methodAnnotationDocumentPaginator(DocumentPaginator, Stream, FlowDirection)Initializes a new instance of the AnnotationDocumentPaginator class based on a specified DocumentPaginator, annotation storage Stream, and text FlowDirection.
Public methodAnnotationDocumentPaginator(DocumentPaginator, AnnotationStore, FlowDirection)Initializes a new instance of the AnnotationDocumentPaginator class based on a specified DocumentPaginator, AnnotationStore, and text FlowDirection.
Top

  NameDescription
Public propertyIsPageCountValidGets a value that indicates whether PageCount is the total number of pages. (Overrides DocumentPaginator.IsPageCountValid.)
Public propertyPageCountGets a value that indicates the number of pages currently formatted. (Overrides DocumentPaginator.PageCount.)
Public propertyPageSizeGets or sets the suggested width and height of each page. (Overrides DocumentPaginator.PageSize.)
Public propertySourceGets the source document that is being paginated. (Overrides DocumentPaginator.Source.)
Top

  NameDescription
Public methodCancelAsyncCancels all asynchronous operations initiated with a given userState object. (Overrides DocumentPaginator.CancelAsync(Object).)
Public methodComputePageCountForces a pagination of the content, updates PageCount with the new total, and sets IsPageCountValid to true. (Overrides DocumentPaginator.ComputePageCount().)
Public methodComputePageCountAsync()Asynchronously, forces a pagination of the content, updates PageCount with the new total, and sets IsPageCountValid to true. (Inherited from DocumentPaginator.)
Public methodComputePageCountAsync(Object)Starts an asynchronous pagination of the content, updates PageCount with the new total, and sets IsPageCountValid to true when it is finished. (Overrides DocumentPaginator.ComputePageCountAsync(Object).)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetPageReturns a DocumentPage together with associated user-annotations for a specified page number. (Overrides DocumentPaginator.GetPage(Int32).)
Public methodGetPageAsync(Int32)Asynchronously returns (through the GetPageCompleted event) the DocumentPage for the specified page number. (Inherited from DocumentPaginator.)
Public methodGetPageAsync(Int32, Object)asynchronously returns a DocumentPage together with associated user-annotations for a specified page number. (Overrides DocumentPaginator.GetPageAsync(Int32, Object).)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventComputePageCountCompletedOccurs when a ComputePageCountAsync operation has finished. (Inherited from DocumentPaginator.)
Public eventGetPageCompletedOccurs when GetPageAsync has completed. (Inherited from DocumentPaginator.)
Public eventPagesChangedOccurs when the document content is changed. (Inherited from DocumentPaginator.)
Top

The AnnotationDocumentPaginator class wraps the DocumentPaginator specified to the AnnotationDocumentPaginator constructor to add the user annotations to the pages for printing.

The following example shows use of the AnnotationDocumentPaginator class.

PrintDialog prntDialog = new PrintDialog();
if ((bool)prntDialog.ShowDialog())
{
    // XpsDocumentWriter.Write() may change the current 
    // directory to "My Documents" or another user selected
    // directory for storing the print document.  Save the 
    // current directory and restore it after calling Write(). 
    string docDir = Directory.GetCurrentDirectory();

    // Create and XpsDocumentWriter for the selected printer.
    XpsDocumentWriter xdw = PrintQueue.CreateXpsDocumentWriter(
                                        prntDialog.PrintQueue);

    // Print the document with annotations. 
    try
    {
        xdw.Write(_annotHelper.GetAnnotationDocumentPaginator(
            _xpsDocument.GetFixedDocumentSequence()));
    }
    catch (PrintingCanceledException)
    {
        // If in the PrintDialog the user chooses a file-based 
        // output, such as the "MS Office Document Image Writer",
        // the user confirms or specifies the actual output 
        // filename when the xdw.write operation executes. 
        // If the user clicks "Cancel" in the filename
        // dialog a PrintingCanceledException is thrown 
        // which we catch here and ignore. 
        // MessageBox.Show("Print output cancelled");
    }

    // Restore the original document directory to "current".
    Directory.SetCurrentDirectory(docDir);
}
// ------------------ GetAnnotationDocumentPaginator ------------------ 
/// <summary> 
///   Returns a paginator for printing annotations.</summary> 
/// <param name="fds">
///   The FixedDocumentSequence containing 
///   the annotations to print.</param> 
/// <returns> 
///   An paginator for printing the document's annotations.</returns> 
public AnnotationDocumentPaginator GetAnnotationDocumentPaginator(
                                            FixedDocumentSequence fds)
{
    return new AnnotationDocumentPaginator(
                   fds.DocumentPaginator, _annotService.Store);
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.
Show:
© 2014 Microsoft