For a WPF WebBrowser control, is there a way to duplicate Internet Explorer's zoom functionality?
In other words, Internet Explorer has the menu View > Zoom > 75%, which renders the web page at 75% scale. Is there a way to make a web browser control, which is embedded in a WPF app, do the same thing?
I've seen this post: WPF WebBrowser - How to Zoom Content?
But it only seems to scale the page and not the page content.
When using the other solutions, I always get errors of kind
I found a solution on this page that worked for me:
With
OLECMDID_OPTICAL_ZOOM
being 63 andOLECMDEXECOPT_DONTPROMPTUSER
being 2.This is not an exact answer since it is for the WinForms control, but perhaps will be useful in case you decide to use it in a WindowsFormsHost instead of the WPF control, which exposes way too little to be useful.
You could use an OLE commands through ExecWB on the ActiveX instance:
OLECMDID_ZOOM
for text size andOLECMDID_OPTICAL_ZOOM
for optical zoom. For example,Some notes:
OLECMDID_GETZOOMRANGE
Here's how I did it:
All the service provider stuff exposes the ActiveX since the WPF WebBrowser control doesn't expose it directly. Aside from that, it's pretty much the same as alexei's solution.