Page 1 of 1

Print preview header and footer

Posted: Wed Jun 08, 2022 6:05 pm
by cris_tico
How can I disable printing preview header and footer?
I tried set WVBrowser1.CoreWebView2PrintSettings.ShouldPrintHeaderAndFooter to false but did not work.


Thanks

Re: Print preview header and footer

Posted: Wed Jun 08, 2022 7:30 pm
by salvadordf
Hi,

The ICoreWebView2PrintSettings properties are only used with PrintToPdf and not with Print.
https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2printsettings?view=webview2-1.0.1210.39

As you can see in the feedback repository, there are some unresolved issues with ICoreWebView2PrintSettings like this one :
https://github.com/MicrosoftEdge/WebView2Feedback/issues/2093

Re: Print preview header and footer

Posted: Wed Jun 08, 2022 7:38 pm
by salvadordf
The TWVBrowser.Print function doesn't exist in the WebView2 API and it's just executing window.print(); in JavaScript.

Read this to add a header and a title using HTML, CSS and JavaScript :
https://stackoverflow.com/questions/1360869/how-to-use-html-to-print-header-and-footer-on-every-printed-page-of-a-document

Re: Print preview header and footer

Posted: Thu Jun 09, 2022 1:43 am
by cris_tico
salvadordf thanks for the tip with the stackoverflow link.
I just didn't notice this simple detail "Settings used by the PrintToPdf method."