How can I convert an HTML page to an image file; like a BMP?

woklet

Member
Joined
Mar 4, 2005
Messages
15
Programming Experience
5-10
I need to convert an html web page to a document, preferably a tiff. I am able to get a 'screen capture', capture specific images, and capture the raw text on an html page. But I would like to capture the whole HTML page, even if there is more to see upon scrolling down. HTML capture to BMP image.

Needs to be in VB.NET - thanks in advance!
 
I'm actually replying to my own post in hopes of generating a possible solution. Here is the code I have thus far...

Dim doc As mshtml.HTMLDocument = DirectCast(Me.AxWebBrowser1.Document, mshtml.HTMLDocument)
Dim bodyElement As mshtml.IHTMLElement

Dim render2 As IHTMLElementRender

bodyElement = doc.body

render2 = bodyElement

Dim BitMap As New Bitmap(600, 400)



Dim g As Graphics = Graphics.FromImage(BitMap)

Dim memDC As IntPtr

Dim CCBHandle As IntPtr

Dim memDC2 As mshtml._RemotableHandle

Dim tt As Integer

memDC = g.GetHdc()

Try

render2.DrawToDC(memDC)

Catch ex As Exception

MsgBox(ex.ToString)

End Try

Try

BitMap.FromHbitmap(memDC)

Catch exc As Exception

MsgBox(Err.Description)

MsgBox(exc.ToString)

End Try

BitMap.Save("c:\newread\test.tif", System.Drawing.Imaging.ImageFormat.Tiff)

MsgBox("Image created!")


I don't get an error on my DrawToDC() function, so I feel like I've rendered my HTML page to the Device Context in memory, but by golly I'm not entirely sure.

Does anyone have further insight in this matter; how to insert what I've rendered into a bitmap? Any thoughts would be helpful.

Thanks much

"Go back to the shadow. You shall not pass."
 
Well I figured out how to capture the Web Browser, scroll down a page, capture again, and continue until I'm at the end. Then I just concatenate all the images together into one. It's "flashy" and a "tad too early 90s", but it works.

Anyone have a method of capturing the Web Browser in one quick, swift stroke? VB.NET

Thanks
Ben
 
Back
Top