Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Print preview header and footer

Post Reply
cris_tico
Posts: 2
Joined: Wed Jun 08, 2022 4:28 pm

Print preview header and footer

Post 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
User avatar
salvadordf
Posts: 4563
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Print preview header and footer

Post 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
User avatar
salvadordf
Posts: 4563
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Print preview header and footer

Post 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
cris_tico
Posts: 2
Joined: Wed Jun 08, 2022 4:28 pm

Re: Print preview header and footer

Post 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."
Post Reply