PrintDocument PrintDocument PrintDocument Class

Defines a reusable object that sends output to a printer.

Syntax

Declaration

public class PrintDocumentpublic class PrintDocumentPublic Class PrintDocument

Inheritance Hierarchy

Remarks

@Windows.UI.Xaml.Printing.PrintDocument.#ctor implements a print list concept whereby pages can be added to the print list, and then various methods can be called on the ongoing print list.

Constructors summary

Initializes a new instance of the PrintDocument class.

Properties summary

Gets a document source reference for this PrintDocument.

Identifies the DocumentSource dependency property.

Methods summary

Adds a XAML root visual element to the print list.

Indicates that the application will not add more pages to the print list, and that the print list is ready to be released.

References the low-level print preview dialog API and invalidates the current print preview.

Sets the specified print page as the current print preview page.

Sets the number of pages prepared for print preview and added to the print list.

Events summary

Occurs when the PrintManager requests the final collection of pages to send to the printer.

Occurs when the PrintManager requests a particular print page to be shown in the preview window.

Occurs when the PrintManager requests the collection of print pages to be shown in the preview window.

Constructors

  • PrintDocument()
    PrintDocument()
    PrintDocument()
    PrintDocument()

    Initializes a new instance of the PrintDocument class.

    public PrintDocument()public New()Public Sub New()public PrintDocument()

Properties

  • DocumentSource
    DocumentSource
    DocumentSource
    DocumentSource

    Gets a document source reference for this PrintDocument.

    public IPrintDocumentSource DocumentSource { get; }public IPrintDocumentSource DocumentSource { get; }Public ReadOnly Property DocumentSource As IPrintDocumentSourcepublic IPrintDocumentSource DocumentSource { get; }

    Property Value

  • DocumentSourceProperty
    DocumentSourceProperty
    DocumentSourceProperty
    DocumentSourceProperty

    Identifies the DocumentSource dependency property.

    public static DependencyProperty DocumentSourceProperty { get; }public static DependencyProperty DocumentSourceProperty { get; }Public Static ReadOnly Property DocumentSourceProperty As DependencyPropertypublic static DependencyProperty DocumentSourceProperty { get; }

    Property Value

Methods

  • AddPage(UIElement)
    AddPage(UIElement)
    AddPage(UIElement)
    AddPage(UIElement)

    Adds a XAML root visual element to the print list.

    public void AddPage(UIElement pageVisual)public void AddPage(UIElement pageVisual)Public Function AddPage(pageVisual As UIElement) As voidpublic void AddPage(UIElement pageVisual)

    Parameters

  • AddPagesComplete()
    AddPagesComplete()
    AddPagesComplete()
    AddPagesComplete()

    Indicates that the application will not add more pages to the print list, and that the print list is ready to be released.

    public void AddPagesComplete()public void AddPagesComplete()Public Function AddPagesComplete() As voidpublic void AddPagesComplete()
  • InvalidatePreview()
    InvalidatePreview()
    InvalidatePreview()
    InvalidatePreview()

    References the low-level print preview dialog API and invalidates the current print preview.

    public void InvalidatePreview()public void InvalidatePreview()Public Function InvalidatePreview() As voidpublic void InvalidatePreview()
  • SetPreviewPage(Int32, UIElement)
    SetPreviewPage(Int32, UIElement)
    SetPreviewPage(Int32, UIElement)
    SetPreviewPage(Int32, UIElement)

    Sets the specified print page as the current print preview page.

    public void SetPreviewPage(Int32 pageNumber, UIElement pageVisual)public void SetPreviewPage(Int32 pageNumber, UIElement pageVisual)Public Function SetPreviewPage(pageNumber As Int32, pageVisual As UIElement) As voidpublic void SetPreviewPage(Int32 pageNumber, UIElement pageVisual)

    Parameters

    • pageNumber
      System.Int32
      System.Int32
      System.Int32

      The sequence number of the page to preview.

    • pageVisual

      The root visual object for the requested print page.

  • SetPreviewPageCount(Int32, PreviewPageCountType)
    SetPreviewPageCount(Int32, PreviewPageCountType)
    SetPreviewPageCount(Int32, PreviewPageCountType)
    SetPreviewPageCount(Int32, PreviewPageCountType)

    Sets the number of pages prepared for print preview and added to the print list.

    public void SetPreviewPageCount(Int32 count, PreviewPageCountType type)public void SetPreviewPageCount(Int32 count, PreviewPageCountType type)Public Function SetPreviewPageCount(count As Int32, type As PreviewPageCountType) As voidpublic void SetPreviewPageCount(Int32 count, PreviewPageCountType type)

    Parameters

Events

  • AddPages
    AddPages
    AddPages
    AddPages

    Occurs when the PrintManager requests the final collection of pages to send to the printer.

    public event AddPagesEventHandler AddPagespublic event AddPagesEventHandler AddPagesPublic Event AddPagespublic event AddPagesEventHandler AddPages

    Remarks

    Provide Windows with printable pages by calling AddPage(UIElement) for each page to be printed. Pass a UIElement that is the printable content to the AddPage(UIElement) method. Call AddPagesComplete() to signal that all of the pages to be printed have been added and Windows can continue with the print job.

    If the user specifies particular pages or a range of pages in the print options UI, only the specified pages should be added to the print list.

  • GetPreviewPage
    GetPreviewPage
    GetPreviewPage
    GetPreviewPage

    Occurs when the PrintManager requests a particular print page to be shown in the preview window.

    public event GetPreviewPageEventHandler GetPreviewPagepublic event GetPreviewPageEventHandler GetPreviewPagePublic Event GetPreviewPagepublic event GetPreviewPageEventHandler GetPreviewPage

    Remarks

    In the handler for this event, call SetPreviewPage(Int32, UIElement) to set the requested page as the current print preview page.

  • Paginate
    Paginate
    Paginate
    Paginate

    Occurs when the PrintManager requests the collection of print pages to be shown in the preview window.

    public event PaginateEventHandler Paginatepublic event PaginateEventHandler PaginatePublic Event Paginatepublic event PaginateEventHandler Paginate

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ComposableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Printing.dll