C# - Know The Height Of Html Content In A Console Application
I have HTML code something like -
Heading |
Solution 1:
Answering my own question -
All I needed to do was adding reference of System.Windows.Forms
in my console application.
After that I was able to use WebBrowser in headless form directly without creating any form element.
After using WebBrowser, I set the height/width of reasonable number. Something like below -
WebBrowserwb=newWebBrowser();
//Setting the page height and width to a reasonable number. So that whatever the content loaded in it gets aligned properly.//For me 3000 works fine for my requirements.
wb.Width = 3000;
wb.Height = 3000;
wb.Url = newUri(htmlFilePath);
//the below code will force the webbrowser control to load the html in it.while (wb.Document.Body == null)
{
Application.DoEvents();
}
intheight= wb.Document.Body.ScrollRectangle.Height;
Post a Comment for "C# - Know The Height Of Html Content In A Console Application"