Can CanvasVirtualControl work as a UIElement for UWP PrintDocument?

0

In attempting to print from a UWP app (in C++/winrt) using CanvasVirtualControl as a source the print UI appears fine but with a blank preview.

The printrequest seems to work and the events for Paginate, etc. are called.

For this test I have stored the CanvasVirtualControl in which the drawing appears. That control serves as the content of a ScrollViewer. The array, m_print_preview_pages, is defined as std::vector of UIElements. I respond to the PrintDocument’s event, SetPreviewPage, with

m_print_document.SetPreviewPage(args.PageNumber(), m_print_preview_pages[args.PageNumber()-1]);

VS output reports an error,

0x80040155 Failed to find proxy registration for IID: ...

Before going any further I’d like to know if this is a dry well. The UWP print sample doesn’t use CanvasVirtualControl. Is this not going to be possible? It’s not clear to me that CanvasVirtualControl is a UIElement as required for the PrintDocument source.

Thanks for any advice on this.

c++-winrt
win2d
asked on Stack Overflow Mar 27, 2019 by user3743210

1 Answer

0

And the answer is: no. It appears that if your UWP app is printing the content of a CanvasControl or CanvasVirtualControl then the UWP print sample is not appropriate guidance; nor is the Print-From-Your-UWP-App documentation. You need to supply PrintManager a CanvasPrintDocument, and it does not have such events as Paginate, etc. If anyone can point to more complete documentation on this it will be welcome; meanwhile I'm working through it. The docs for the Microsoft.Graphics.Canvas.Printing namespace are a starting point.

answered on Stack Overflow Apr 1, 2019 by user3743210

User contributions licensed under CC BY-SA 3.0