3

I have an WindowsMobile 6.5 (running .NET CF 2.0) application that embed a WebBrowser control that render some content (generated remotely). I want to get all the web page content as a Bitmap, to be able to send it to a printer (sadly this printer do not supports printing HTML).

I know this question was already asked here: Get bitmap of an web page using WebBrowser Control in .net compact framework

But there are no viable solution for the .NET Compact Framework. WebBrowser.DrawToBitmap() do not exists in .NET Compact Framework.

Please ask me if you need more details.

Community
  • 1
  • 1
Pierre-David Belanger
  • 1,004
  • 1
  • 11
  • 19

2 Answers2

1

You need to use another library or API that does HTML to bitmap conversion, this way all you need to do is send the document text or outerhtml to the API, making sure all links in html page are absolute not relative, or has a base tag in it, let the API do the conversion, then send bitmap to printer. So if you can't do it directly I would search for a HTML to bitmap API as the second option to resolve your question, or as a fallback option.

.net might have such an API and I'm sure there would be many third party ones to choose from if you can't do it the preferred way.

Erx_VB.NExT.Coder
  • 4,838
  • 10
  • 56
  • 92
0
string url = @"https://screenshotmachine.com/serve.php?img=example-org-FULL-1bdf72.png";

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
    Bitmap bmp = new Bitmap(reader.ReadToEnd());
}
Redwolf
  • 540
  • 4
  • 17