C# browser zoom
Solution 1
You can do this by setting body
zoom
atribute:
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("http://google.com");
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.Body.Style = "zoom:300%;";
}
Solution 2
in ie, if position fixed used, css zoom not work. u must use browser zoom in that case.
SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
public Form1()
{
InitializeComponent();
IE.DownloadComplete += new DWebBrowserEvents2_DownloadCompleteEventHandler(IE_DownloadComplete);
object URL = "wcms.hankookilbo.com";
IE.Visible = true;
IE.Navigate2(ref URL);
this.Visible = false;
}
private void IE_DownloadComplete()
{
IE.ExecWB(OLECMDID.OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, 200, 0);
}
Solution 3
I realize that this is an old thread but I found something that seems to work really well. The problem with using the Document.Body zoom method is that your page will not be centered in the browser panel. Here is what I am using, it just uses the CONTROL + to zoom in.
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
SendKeys.Send("^{+}");
}
For each SendKeys.Send("^{+}"); it will zoom the page 25% (125%, 150%, etc...)
Just remember to set the DocumentCompleted action to webBrowser1_DocumentCompleted and you will be good to go.
Gabriel Gould
Updated on January 09, 2020Comments
-
Gabriel Gould over 4 years
I am building a C# application and using the web browser from the visual studio toolkit.. is it possible to enable this browser to do pinch zoom etc when browsing large images/pdf's for use on a tablet?
-
Gabriel Gould over 11 yearsThanks.. Will give this a try