I\'m using a web browser control to display some on-the-fly generated HTML documents in my application.
Problem is, on my machine said documents are displayed kinda
Problem is, on my machine said documents are displayed kinda zoomed in.
Internet Explorer respects to the windows scale settings. As a result the size that you will see on WebBrowser control on a system having scaling 100, is different from the size which you see on WebBrowser control on a system having scaling 150, while both WebBrowser controls set to 100% zoom.
The reason is because of scaling. The scaling factor is same as Windows scaling factor divided by 100 or physicalScreenHeight/logicalScreenHeight.
As far as I can see, there's no easy way to set the predefined zoom level programmatically.
In fact there is. To change the zoom level of Web Browser control, you can get IWebBrowser2 instance from the WebBrowser.ActiveXInstance property and then using its ExecWB method, set set the zoom this way:
int OLECMDID_OPTICAL_ZOOM = 63;
int OLECMDEXECOPT_DONTPROMPTUSER = 2;
dynamic iwb2 = webBrowser1.ActiveXInstance;
object zoom = 200; //The value should be between 10 , 1000
iwb2.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, zoom, zoom);
You can also add reference to Microsoft Internet Controls (SHDocVw.dll) and cast WebBrowser.ActiveXInstance to SHDocVw.WebBrowser and use ExecWB method. But above code does the trick without adding any reference.
Web browser zoom is completely different from CSS3 zoom. But you may want to know about how to set document body zoom: webBrowser1.Document.Body.Style = "zoom:200%";
All above codes should be run after document has been completed.