2

Does anyone know how I get the full page height and width in GeckoFX? In the IE WebBrowser object, I can look at WebBrowser.Document.Body.ScrollRectangle. (The objective here is to take a screenshot of the entire page)

Thanks!

carlbenson
  • 3,177
  • 5
  • 35
  • 54

2 Answers2

2

I'm using Hindle's fork of GeckoFX, and here's how I do it:

var width = _browser.Document.ActiveElement.ScrollWidth;
var height = _browser.Document.ActiveElement.ScrollHeight;

I use this to create thumbnails of the page. Note, this gives us the size taken up by the first page we navigated to, not necessarily the size of the current page. I get around that by using different browser instances for each page I'm thumbnailing.

John Hatton
  • 1,734
  • 18
  • 20
  • John, I need to create a thumbnail of SVG document on the page. Could you elaborate on the method you use? – Yuriy Gettya Nov 18 '13 at 17:27
  • @YuriyGettya, It comes down to var docImage = browser.GetBitmap((uint) browser.Width, (uint) browser.Height); There are some edge cases you can check out in the code of my full HTMLThumbnailer: https://github.com/BloomBooks/BloomDesktop/blob/master/src/BloomExe/HtmlThumbNailer.cs. Note, since I wrote it, geckofx has acquired more image-related code, so I'd see if can't be done more simply now, using that. See https://bitbucket.org/geckofx/geckofx-18.0/src/7c0672b60987b99ab4a0c4cdd374c0cdce438086/Geckofx-Core/ImageCreator.cs – John Hatton Nov 18 '13 at 19:25
0

I did this:

BROWSER = new GeckoWebBrowser();
BROWSER.Height = 1920;
BROWSER.Width = 1080;

It seems working.


Visual Studio installed: Community 2019

GeckoFx installed: v45.0.34 (with NuGet package manager)

Giuse Petroso
  • 557
  • 6
  • 7