Click or drag to resize
CanvasPrintDocumentPreview Event
Hook this event to draw print previews.

Namespace:  Microsoft.Graphics.Canvas.Printing
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version:
public event TypedEventHandler<CanvasPrintDocument, CanvasPreviewEventArgs> Preview


Type: Windows.FoundationTypedEventHandlerCanvasPrintDocument, CanvasPreviewEventArgs

PrintTaskOptionsChanged will always be raised at least once before the first Preview event has been raised.

The Preview event is raised when the print preview dialog needs a page to be drawn. The provided DrawingSession is configured correctly for drawing the page, with the DPI configured correctly so that the preview size matches the page size.

void OnPreview(CanvasPrintDocument sender, CanvasPreviewEventArgs args)
    PageDescription pageDesc = args.PrintTaskOptions.GetPageDescription(args.PageNumber);
    Size pageSize = pageDesc.PageSize;

    // Draws a rectangle around the entire page
    args.DrawingSession.DrawRect(0, 0, (float)pageSize.Width, (float)pageSize.Height, Colors.Black, 1);

See Also