I am using WebKit.NET to integrate a browser component in my C# application. The problem is I can only capture the visible part in the browser window with a screenshot. Is there a way to capture the screenshot of the whole page?
Seems that it is kind of possible by using NativeMethods.SendMessage, although this can screw up the message queue, could you use http://cutycapt.sourceforge.net/ or perhaps http://iecapt.sourceforge.net/ or http://labs.awesomium.com/capturing-web-pages-with-c-net/?
I use WebBrowser instead; ScrollBarsEnabled = false
let me capture whole page.
Here is some code:
protected override void Render(HtmlTextWriter writer)
{
StringBuilder builder = new StringBuilder();
HtmlTextWriter htw = new HtmlTextWriter(new StringWriter(builder));
base.Render(htw);
string html = builder.ToString();
_Generate(html);
}
private void _Generate(string html)
{
var browser = new WebBrowser { ScrollBarsEnabled = false };
DisplayHtml(html, browser);
browser.DocumentCompleted += WebBrowser_DocumentCompleted;
while (browser.ReadyState != WebBrowserReadyState.Complete)
Application.DoEvents();
browser.Dispose();
}
private void DisplayHtml(string html, WebBrowser browser)
{
browser.Navigate("about:blank");
if (browser.Document != null)
{
browser.Document.Write(string.Empty);
}
browser.DocumentText = html;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With