html to image

S

Sharon

Hi all.
My goal is to convert html elements to bitmap.
So the first step would be to parse the html.
System.Windows.Forms.WebBrowser even has a method called DrawToBitmap,
which makes the whole thing much easier.
The problem is that WebBrowser cannot be used in a dll.
I can understand why WebBrowser is in System.Windows.Forms namespace,
but i don't understand how classes like HtmlElement belong to
System.Windows.Forms.
So my questions are:
1. is there a way to use WebBrowser in a console application or dll?
2. why is there no separation between the visual control and the parser?
Thanks.
Sharon.
 
N

Nicholas Paldino [.NET/C# MVP]

Sharon,

Instead of doing it yourself, you can have the operating system do it
for you. There is an interface in COM called IExtractImage which
implementations will use to create thumbnail images. All you have to do is
specify the size of the image you want to render and then make the call to
Extract.

There is an article on vbaccelerator.net titled "Thumbnail Extraction
Using the Shell", located at (watch for line wrap):

http://www.vbaccelerator.com/home/NET/Code/Libraries/Shell_Projects/Thumbnail_Extraction/article.asp

This should tell you all you need to know.

Hope this helps.
 
L

Larry Lard

Sharon said:
Hi all.
My goal is to convert html elements to bitmap.
So the first step would be to parse the html.

Well, that's debatable, but...

A great library for dealing exactly this problem is HtmlAgilityPack. It
will convert even 'real world' (ie non-strict) html into a nice tidy
DOM.
 
S

Sharon

Thanks Nicholas for your reply.
I will try your suggestion, but i doubt it can help me
as i need to render segments of the html doc.
I'm really frustrated by the fact, that there is no
stand alone html dom parser in the framework.
There is one, but it is bundled in the WebBrowser control.
Sharon.

Nicholas Paldino said:
Sharon,

Instead of doing it yourself, you can have the operating system do it
for you. There is an interface in COM called IExtractImage which
implementations will use to create thumbnail images. All you have to do is
specify the size of the image you want to render and then make the call to
Extract.

There is an article on vbaccelerator.net titled "Thumbnail Extraction
Using the Shell", located at (watch for line wrap):

http://www.vbaccelerator.com/home/NET/Code/Libraries/Shell_Projects/Thumbnail_Extraction/article.asp

This should tell you all you need to know.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Sharon said:
Hi all.
My goal is to convert html elements to bitmap.
So the first step would be to parse the html.
System.Windows.Forms.WebBrowser even has a method called DrawToBitmap,
which makes the whole thing much easier.
The problem is that WebBrowser cannot be used in a dll.
I can understand why WebBrowser is in System.Windows.Forms namespace,
but i don't understand how classes like HtmlElement belong to
System.Windows.Forms.
So my questions are:
1. is there a way to use WebBrowser in a console application or dll?
2. why is there no separation between the visual control and the parser?
Thanks.
Sharon.
 
S

Sharon

Larry Lard said:
By passing it to a component that does both the parsing and the
rendering!

Yes, i was hoping to use the WebBrowser class, but can do that only in
windows forms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top