ערוך

שתף באמצעות


AnnotationDocumentPaginator Class

Definition

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

public ref class AnnotationDocumentPaginator sealed : System::Windows::Documents::DocumentPaginator
public sealed class AnnotationDocumentPaginator : System.Windows.Documents.DocumentPaginator
type AnnotationDocumentPaginator = class
    inherit DocumentPaginator
Public NotInheritable Class AnnotationDocumentPaginator
Inherits DocumentPaginator
Inheritance
AnnotationDocumentPaginator

Examples

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);
}
Dim prntDialog As New PrintDialog()
If CBool(prntDialog.ShowDialog()) Then
    ' 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().
    Dim docDir As String = Directory.GetCurrentDirectory()

    ' Create and XpsDocumentWriter for the selected printer.
    Dim xdw As XpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(prntDialog.PrintQueue)

    ' Print the document with annotations.
    Try
        xdw.Write(_annotHelper.GetAnnotationDocumentPaginator(_xpsDocument.GetFixedDocumentSequence()))
    Catch e1 As 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.
    End Try

    ' Restore the original document directory to "current".
    Directory.SetCurrentDirectory(docDir)
End If
// ------------------ 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);
}
' ------------------ 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 Function GetAnnotationDocumentPaginator(ByVal fds As FixedDocumentSequence) As AnnotationDocumentPaginator
    Return New AnnotationDocumentPaginator(fds.DocumentPaginator, _annotService.Store)
End Function

Remarks

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

Constructors

AnnotationDocumentPaginator(DocumentPaginator, AnnotationStore)

Initializes a new instance of the AnnotationDocumentPaginator class based on a specified DocumentPaginator and AnnotationStore.

AnnotationDocumentPaginator(DocumentPaginator, AnnotationStore, FlowDirection)

Initializes a new instance of the AnnotationDocumentPaginator class based on a specified DocumentPaginator, AnnotationStore, and text FlowDirection.

AnnotationDocumentPaginator(DocumentPaginator, Stream)

Initializes a new instance of the AnnotationDocumentPaginator class based on a specified DocumentPaginator and annotation storage Stream.

AnnotationDocumentPaginator(DocumentPaginator, Stream, FlowDirection)

Initializes a new instance of the AnnotationDocumentPaginator class based on a specified DocumentPaginator, annotation storage Stream, and text FlowDirection.

Properties

IsPageCountValid

Gets a value that indicates whether PageCount is the total number of pages.

PageCount

Gets a value that indicates the number of pages currently formatted.

PageSize

Gets or sets the suggested width and height of each page.

Source

Gets the source document that is being paginated.

Methods

CancelAsync(Object)

Cancels all asynchronous operations initiated with a given userState object.

ComputePageCount()

Forces a pagination of the content, updates PageCount with the new total, and sets IsPageCountValid to true.

ComputePageCountAsync()

Asynchronously, forces a pagination of the content, updates PageCount with the new total, and sets IsPageCountValid to true.

(Inherited from DocumentPaginator)
ComputePageCountAsync(Object)

Starts an asynchronous pagination of the content, updates PageCount with the new total, and sets IsPageCountValid to true when it is finished.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetPage(Int32)

Returns a DocumentPage together with associated user-annotations for a specified page number.

GetPageAsync(Int32)

Asynchronously returns (through the GetPageCompleted event) the DocumentPage for the specified page number.

(Inherited from DocumentPaginator)
GetPageAsync(Int32, Object)

Asynchronously returns a DocumentPage together with associated user-annotations for a specified page number.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnComputePageCountCompleted(AsyncCompletedEventArgs)

Raises the ComputePageCountCompleted event.

(Inherited from DocumentPaginator)
OnGetPageCompleted(GetPageCompletedEventArgs)

Raises the GetPageCompleted event.

(Inherited from DocumentPaginator)
OnPagesChanged(PagesChangedEventArgs)

Raises the PagesChanged event.

(Inherited from DocumentPaginator)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Events

ComputePageCountCompleted

Occurs when a ComputePageCountAsync operation has finished.

(Inherited from DocumentPaginator)
GetPageCompleted

Occurs when GetPageAsync has completed.

(Inherited from DocumentPaginator)
PagesChanged

Occurs when the document content is changed.

(Inherited from DocumentPaginator)

Applies to