WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

Print button not working by using WebView2 to render a PDF in an UWP APP

Open supperwu opened this issue 2 years ago • 11 comments

Description

I'm trying to create an UWP app and embed a WebView2 in WinUI 2. Then I try to render a PDF host in a remote server in the WebView2, the PDF can be rendered normally, but when I click the print button in the toolbar, nothing happen and no printing preview dialog display. May I know it's a known issue? Thanks.

Version

SDK: 1.0.1418.22 Runtime: 109.0.1518.52 Framework: UWP WinUI 2.8.1 OS: Win10 20H2

Repro Steps

1: Try to create an UWP app and embed a WebView2 in the main page, follow the guide https://learn.microsoft.com/en-us/microsoft-edge/webview2/get-started/winui2

2: Render a PDF host in remote server with the WebView2

3: Try to press the print button in the toolbar.

supperwu avatar Jan 18 '23 10:01 supperwu

Thanks for your detailed issue. Unfortunately, at the moment its a known limitation that printing in a UWP app is not supported. This is described a bit more in the WebView2 WinUI2 doc.

david-risney avatar Jan 19 '23 19:01 david-risney

Not sure if it's possible to enhance it like this: 1: Let developer to override the default print behavior 2: Or provide an interface, developer can add customized button in the PDF toolbar Which means developer can implement the print function by themselves.

supperwu avatar Feb 04 '23 04:02 supperwu

@supperwu could you please check if suggestions from https://github.com/MicrosoftEdge/WebView2Feedback/issues/2638 are useful for your scenario to disable the default print behavior.

And then you modify/add a print menu in the context menu, and implement the print function using (PrintToPDFAsync API combining with UWP printing APIs to print to a printer).

monica-ch avatar Feb 06 '23 23:02 monica-ch

@monica-ch Thanks for the reply. Yes, we can add a print menu in the context menu. But from the user experience perspective, it's better to trigger the print in the PDF toolbar, so for UWP, the WebView2 will support print PDF in the furture?

supperwu avatar Feb 11 '23 02:02 supperwu

@supperwu I agree. Yes, we are planning to support printing in UWP in future, but that is low priority in the backlog. Until then I would recommend you hide the print from the pdf toolbar using HiddenPdfToolbarItems and provide a way to print using our PrintToPdfAsync API.

monica-ch avatar Feb 17 '23 23:02 monica-ch

When will this issue be solved?

pubtom avatar Sep 08 '23 12:09 pubtom

@monica-ch Any update on this issue? When will this issue be solved?

pubtom avatar Jan 03 '24 09:01 pubtom

Any update?

pubtom avatar Feb 22 '24 14:02 pubtom

@pubtom We appreciate your interest in print support for UWP apps. Currently, this feature is a lower priority on our backlog. However, we recommend exploring the suggestions from the thread mentioned above for printing experience using native APIs and WV2 PrintToPDFAsync.

monica-ch avatar Feb 22 '24 17:02 monica-ch

Any update on this issue?

pubtom avatar Aug 13 '24 21:08 pubtom

@pubtom Nothing has been changed from our side.

monica-ch avatar Aug 13 '24 21:08 monica-ch