Reputation: 9867
I need to get the rendered height of a web page when rendered in IE.
I'm currently using the WebBrowser control to load an HTML page and then find the document's clientHeight (or scrollHeight, I forget which). This works well.
The problem is, I need this code to run from a web service as a result of an API call and launching a Windows Form based control to load in the WebBrowser control is ugly and (I assume) incredibly resource hungry.
So, is there a headless browser implementation out there that would allow me to figure out the likely height of the rendered HTML? I know this wouldn't work for iframes, divs that scroll etc, and it doesn't need to be super accurate (within 200px would be fine).
The HTML pages we test range from around 700px high to many thousands of pixels high, so figuring out the rough height would be perfect. The HTML used tends to be quite simple, as these pages are actually HTML emails, extracted from the email and sent to a web browser.
Upvotes: 4
Views: 649
Reputation: 4492
This really depends on the browser and its rendering engine. You will probably have to use a renderer.
If your HTML is a standard one, you should be able to use HTMLayout's in-memory rendering capability and results will be similar to other browsers.
It has a .NET wrapper at http://code.google.com/p/nabu-library/
Upvotes: 1