MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
449 stars 55 forks source link

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

Open supperwu opened 1 year ago

supperwu commented 1 year ago

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.

david-risney commented 1 year ago

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.

supperwu commented 1 year ago

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.

monica-ch commented 1 year ago

@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).

supperwu commented 1 year ago

@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?

monica-ch commented 1 year ago

@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.

pubtom commented 1 year ago

When will this issue be solved?

pubtom commented 9 months ago

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

pubtom commented 8 months ago

Any update?

monica-ch commented 8 months ago

@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.

pubtom commented 2 months ago

Any update on this issue?

monica-ch commented 2 months ago

@pubtom Nothing has been changed from our side.