Click or drag to resize
CanvasPrintDocumentPrint Event
Hook this event to print the document.

Namespace:  Microsoft.Graphics.Canvas.Printing
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public event TypedEventHandler<CanvasPrintDocument, CanvasPrintEventArgs> Print

Value

Type: Windows.FoundationTypedEventHandlerCanvasPrintDocument, CanvasPrintEventArgs
Remarks

This is raised after the user presses the "Print" button on the print preview dialog. The app should draw each page to be printed, calling CreateDrawingSession for each page. For example:

void OnPrint(CanvasPrintDocument sender, CanvasPrintEventArgs args)
{
    for (uint pageNumber = 1; pageNumber <= this.numberOfPages; ++pageNumber)
    {
        using (var ds = args.CreateDrawingSession())
        {
            this.DrawPage(ds, pageNumber, args.PrintTaskOptions.GetPageDescription(pageNumber);
        }
    }
}

By default, the Dpi is set to match the printer DPI. If an app has a reason to change the DPI then it can do this before the first call to CreateDrawingSession.

See Also