0

Is it possible?

var browser = new ChromiumWebBrowser(string.Empty);
browser.LoadHtml("<html goes here>", @"http://www.google.com/", System.Text.Encoding.UTF8);
browser.Print();

It throws an exception, but work fine when loaded into a form.

carva
  • 35
  • 7
  • You've tagged WinForms and OffScreen, which are you using? – amaitland Mar 04 '22 at 09:41
  • I removed the WinForms tag. I want to do this Offscreen – carva Mar 04 '22 at 09:59
  • OffScreen is a separate Nuget package https://www.nuget.org/packages/CefSharp.OffScreen/ is that the package you are using? Or are you using CefSharp.Winforms? – amaitland Mar 04 '22 at 19:24
  • I use the WinForms package, but I did realize there was an Offscreen package. Does that support loading html and open print dialog or print to pdf? – carva Mar 05 '22 at 08:05
  • The OffScreen implementation uses the same underlying browser engine as the WPF implementation. You can print to PDF without displaying any output to the user. You can actually print as well though a print dialog will be displayed by default. https://github.com/cefsharp/CefSharp.MinimalExample/blob/master/CefSharp.MinimalExample.OffScreen/Program.cs has a very simple set of examples. – amaitland Mar 05 '22 at 19:23
  • Thanks it worked. Is there a way to get access the print dialog? – carva Mar 07 '22 at 12:19
  • What do you mean by get access the print dialog? – amaitland Mar 07 '22 at 19:22
  • Open the printdialog as a dialog/format to get the buttons clicked(ok or cancel). – carva Mar 08 '22 at 07:34
  • http://cefsharp.github.io/api/98.1.x/html/M_CefSharp_WebBrowserExtensions_Print_1.htm – amaitland Mar 08 '22 at 19:21

0 Answers0