Welcome Guest Search | Active Topics | Sign In | Register

Printing a html document Options
MrpDude
Posted: Wednesday, January 17, 2024 4:24:38 PM
Rank: Member
Groups: Member

Joined: 9/26/2023
Posts: 10
What is the purpose of webview1.print? When does it work and do I have to have it open in a browser? or can I print without a browser just using webview1?
eo_support
Posted: Wednesday, January 17, 2024 4:32:23 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi,

WebView IS the browser engine. You can use it to display a web page (and print it if you want to) in your application. You can also use it load page off screen and then do other things such as examine the page, automate login, etc. Internally our HTML to PDF converter uses WebView to render a page to PDF.

Thanks!
MrpDude
Posted: Thursday, January 18, 2024 4:13:42 AM
Rank: Member
Groups: Member

Joined: 9/26/2023
Posts: 10
My programming is pretty simple:
WebView.LoadHtml(MyString)
WebView.Print(MyPrinterSettings, MyPageSetitngs)

It does nothing.
I even tried putting in the event handler to make sure it was done loading but I can't even get that to fire.
eo_support
Posted: Thursday, January 18, 2024 10:02:41 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi,

All the calls are asynchronous. So you will need to wait for it to finish. For example:

Code: C#
//Use LoadHtmlAndWait instead of LoadHtml
webView.LoadHtmlAndWait(MyString);

//Call WaitOne after you call Print
webView.Print(MyPrinterSettings, MyPageSetitngs).WaitOne();


Thanks!
MrpDude
Posted: Thursday, January 18, 2024 11:27:06 AM
Rank: Member
Groups: Member

Joined: 9/26/2023
Posts: 10
It now stops at the first line and will not continue. I then remove the 'AndWait' from the load line and it permanently stops at the print line.
eo_support
Posted: Thursday, January 18, 2024 11:29:43 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
How did you create your WebView object?
MrpDude
Posted: Thursday, January 18, 2024 12:53:46 PM
Rank: Member
Groups: Member

Joined: 9/26/2023
Posts: 10
VB.net
'Dim WebView As New WebView
eo_support
Posted: Thursday, January 18, 2024 1:07:57 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
You can't do that. If you use the WebView with UI (when the page is displayed on screen), you can follow either one of these methods:

https://www.essentialobjects.com/doc/webbrowser/start/winform.html
https://www.essentialobjects.com/doc/webbrowser/start/wpf.html
https://www.essentialobjects.com/doc/webbrowser/start/webview.html

If you use WebView without actually display the page on screen, you need to follow the steps here:

https://www.essentialobjects.com/doc/webbrowser/start/webview_no_ui.html

Thanks!
MrpDude
Posted: Wednesday, January 24, 2024 11:32:05 PM
Rank: Member
Groups: Member

Joined: 9/26/2023
Posts: 10
I have a form with a webcontrol in it, I then a webview into the webcontrol and load the page. All works well. When I use the webview.print, it prints be not in color. The logo prints in color but not colored buttons (maybe background color option?). Any ideas why and what I can do?
eo_support
Posted: Thursday, January 25, 2024 9:37:01 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi,

This is just how web page printing works. By default the browser engine automatically adjust background when printing to save ink. You can turn off such adjusting with the following CSS rule:

Code: CSS
body{
  -webkit-print-color-adjust:exact !important;
  print-color-adjust:exact !important;
}


Please let us know if this works for you.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.