For my application, it is very important the calculate the the location of each CssBox.
I followed the instruction at:
https://htmlrenderer.codeplex.com/discussions/484135
I tried to change the internal class to public so that I can call from outside application.
However, no matter what i did, the location data I got from rectangle is always 0, x=0, y=0, everything =0. Please let me know how do I obtain the Height/Width, X, Y of each CssBox.
My code as below.
I followed the instruction at:
https://htmlrenderer.codeplex.com/discussions/484135
I tried to change the internal class to public so that I can call from outside application.
However, no matter what i did, the location data I got from rectangle is always 0, x=0, y=0, everything =0. Please let me know how do I obtain the Height/Width, X, Y of each CssBox.
My code as below.
public void Execute(Webpage page)
{
HtmlRenderer.HtmlContainer hc = new HtmlRenderer.HtmlContainer();
hc.SetHtml(page.Source, null);
InsertTag(hc.Root, 0, 0);
}
private void InsertTag(CssBox box, int parenttagid, int siblingindex)
{
string tagname = string.Empty;
if (box.HtmlTag != null)
{
tagname= box.HtmlTag.Name;
}
var rect = box.Rectangles; /// all 0
var bounds = box.Bounds; /// all 0
var clientrect = box.ClientRectangle; /// all 0
var myownrect = box.GetElementRectangle(); //copy code from HtmlContainer.
// dosomething here.
foreach (var item in box.Boxes)
{
InsertTag(item, parenttagid, 0);
}
}