I'm working on a windows service in c# 4.0 wich transform different file in image (tif and jpeg)
I have a problem when i want to convert a html file (usually an e-mail) in image.
I use WebBrowser
var browser = new WebBrowser();
browser.DocumentCompleted += this.BrowserDocumentCompleted;
browser.DocumentText = html;
and DrawToBitmap
var browser = sender as WebBrowser;
Rectangle body = new Rectangle(browser.Document.Body.ScrollRectangle.X * scaleFactor,
browser.Document.Body.ScrollRectangle.Y * scaleFactor,
browser.Document.Body.ScrollRectangle.Width * scaleFactor,
browser.Document.Body.ScrollRectangle.Height * scaleFactor);
browser.Height = body.Height;
Bitmap output = new Bitmap(body.Width, body.Height);
browser.DrawToBitmap(output, body);
It works fine for small or medium html, but with long html (like 22 000 height px or more) I have GDI exeptions on DrawToBitmap :
Invalid parameter
Not an image GDI+ valid
According to internet, this kind of error append because the image is too big.
My question : How can i convert html in X images (pagination) without generate the big image and crop after, and if it's possible without using library.
Thank you in advance.
Edit : I found a tricky solution : surround the html with a div witch gonna set the page and another for the offset, for exemple :
<div style="height:3000px; overflow:hidden">
<div style="margin-top:-3000px">
But this solution can crop on a line of text or in the middle of an image...