CanvasPrintDocumentPreview Event |
Namespace: Microsoft.Graphics.Canvas.Printing
public event TypedEventHandler<CanvasPrintDocument, CanvasPreviewEventArgs> Preview
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); }