0

I'm trying to take full height of a web page in WebKit Browser. Document.Bounds.Height doesn't work, Document.Height doesn't work, Document.ClientSize.Height doesn't work, Document.Bottom doesn't work. They all depend on the size of the window.

P.S.: I'm trying to capture snapshot of a web page, I just need sizes of the web page as Width and Height after navigating the page via WebKit Browser Control, the rest is easy. Btw, I couldn't find any useful information about WebKit.Interop; if there is a trick for this operation, please let me know.

competent_tech
  • 44,465
  • 11
  • 90
  • 113
Mikael
  • 127
  • 2
  • 10

1 Answers1

0

Here is the solution:

To scroll down to the end of the page, following code can be used:

   int prevx;
   WebKit.WebBrowser browser;    //Assume created by drag-and-drop.
   while(true) {
      prevx = browser.ScrollOffset.X;
      browser.ScrollOffset = new Point(prevx+1000,0);
      if(prevx == browser.ScrollOffset.X) 
            break;
   }

So now, browser.ScrollOffset.X will return final scroll offset. By following code, we can take total width of a web page:

   int totalHeight = browser.ScrollOffset.X + browser.Width;

Same process should be done for Height, in Y-axis.

Community
  • 1
  • 1
Mikael
  • 127
  • 2
  • 10