By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,110 Members | 1,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,110 IT Pros & Developers. It's quick & easy.

Convert HTML to Image

P: n/a
Dear All Experts

I would like to know how to convert a HTML into Image using C#. Or allow me
contains HTML code (parsed) in Image? I also tried this way but it just
display the character "<" & ">" directly....

I have done googling, but all return shareware. I would like to know how to
programming...but not using shareware...

Thanks all.

Jul 13 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
The closest solution i can think of is to use Office's COM object to convert
html pages to word documents, and then convert the word documents to JPEG(or
other image) files.

However if you or anyone found a better solution, please let me know. I am
fairly interested in this topic too.

Z.
fl*****@gmail.com

"PenguinPig" wrote:
Dear All Experts

I would like to know how to convert a HTML into Image using C#. Or allow me
contains HTML code (parsed) in Image? I also tried this way but it just
display the character "<" & ">" directly....

I have done googling, but all return shareware. I would like to know how to
programming...but not using shareware...

Thanks all.

Jul 13 '06 #2

P: n/a
A browser does exactly what he wants. It converts HTML to an image, which is
painted on the Client rectangle of the browser.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.
"Zhenzhong Xu" <Zh*********@discussions.microsoft.comwrote in message
news:50**********************************@microsof t.com...
The closest solution i can think of is to use Office's COM object to
convert
html pages to word documents, and then convert the word documents to
JPEG(or
other image) files.

However if you or anyone found a better solution, please let me know. I am
fairly interested in this topic too.

Z.
fl*****@gmail.com

"PenguinPig" wrote:
>Dear All Experts

I would like to know how to convert a HTML into Image using C#. Or allow
me
contains HTML code (parsed) in Image? I also tried this way but it just
display the character "<" & ">" directly....

I have done googling, but all return shareware. I would like to know how
to
programming...but not using shareware...

Thanks all.


Jul 14 '06 #3

P: n/a
Dear Kevin

Then how can I capture this image? Which class I should use? Since I am not
expert in this skill...
Thanks

"Kevin Spencer" <uc*@ftc.govwrote in message
news:u4**************@TK2MSFTNGP04.phx.gbl...
A browser does exactly what he wants. It converts HTML to an image, which
is
painted on the Client rectangle of the browser.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.
"Zhenzhong Xu" <Zh*********@discussions.microsoft.comwrote in message
news:50**********************************@microsof t.com...
The closest solution i can think of is to use Office's COM object to
convert
html pages to word documents, and then convert the word documents to
JPEG(or
other image) files.

However if you or anyone found a better solution, please let me know. I
am
fairly interested in this topic too.

Z.
fl*****@gmail.com

"PenguinPig" wrote:
Dear All Experts

I would like to know how to convert a HTML into Image using C#. Or
allow
me
contains HTML code (parsed) in Image? I also tried this way but it just
display the character "<" & ">" directly....

I have done googling, but all return shareware. I would like to know
how
to
programming...but not using shareware...

Thanks all.



Jul 15 '06 #4

P: n/a
I did some research on this and i found a solution which is not particularly
easy to implement, but it is doable.

if you want to do all these programatically, it is not easy.

First of all, you'll need to transform whatever Html you want to a new xhtml
file/stream, (XHTML is a newer generation of html markup stated in XML). Or
you can configure your ASP.Net application to render XHTML content.

Step 2: you'll need to transform XHTML to FO(formating object language)
using a XML Stylesheet (XSL transformation).

Step 3, Convert FO file/stream to a PDF file. You can achieve this step by
using an opensource compiled dll called nfop which is hosted on
sourceforge.net.

Step 4. Convert PDF file/stream to an image file/stream. I am aware there
are some third party API out there for doing this step, but they are not
cheap unless you want to implement your own converter. You can probably skip
this step if you can find an API to convert XSL-FOs to images directly.

So basically, here is the streamline process.

HTML ------->XHTML -----FO ---------PDF ------------JPEG
XSL NFOP Converter

Let me know if you have any questions.

Zhenzhong
fl*****@gmail.com

"PenguinPig" wrote:
Dear Kevin

Then how can I capture this image? Which class I should use? Since I am not
expert in this skill...
Thanks

"Kevin Spencer" <uc*@ftc.govwrote in message
news:u4**************@TK2MSFTNGP04.phx.gbl...
A browser does exactly what he wants. It converts HTML to an image, which
is
painted on the Client rectangle of the browser.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.
"Zhenzhong Xu" <Zh*********@discussions.microsoft.comwrote in message
news:50**********************************@microsof t.com...
The closest solution i can think of is to use Office's COM object to
convert
html pages to word documents, and then convert the word documents to
JPEG(or
other image) files.
>
However if you or anyone found a better solution, please let me know. I
am
fairly interested in this topic too.
>
Z.
fl*****@gmail.com
>
"PenguinPig" wrote:
>
>Dear All Experts
>>
>I would like to know how to convert a HTML into Image using C#. Or
allow
>me
>contains HTML code (parsed) in Image? I also tried this way but it just
>display the character "<" & ">" directly....
>>
>I have done googling, but all return shareware. I would like to know
how
>to
>programming...but not using shareware...
>>
>Thanks all.
>>
>>
>>
>>


Jul 17 '06 #5

P: n/a
the other alternative as Kevin stated is: use some WIN32 API to capture the
browser's window image.

here is a link to a sample project:
http://www.codeproject.com/cs/media/IECapture.asp

of course, using this method means you'll have an instance of browser
running for each convertion process. Thus you probably don't want to do this
if you are planning to implement a web service of some sort.

Z.

"PenguinPig" wrote:
Dear Kevin

Then how can I capture this image? Which class I should use? Since I am not
expert in this skill...
Thanks

"Kevin Spencer" <uc*@ftc.govwrote in message
news:u4**************@TK2MSFTNGP04.phx.gbl...
A browser does exactly what he wants. It converts HTML to an image, which
is
painted on the Client rectangle of the browser.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.
"Zhenzhong Xu" <Zh*********@discussions.microsoft.comwrote in message
news:50**********************************@microsof t.com...
The closest solution i can think of is to use Office's COM object to
convert
html pages to word documents, and then convert the word documents to
JPEG(or
other image) files.
>
However if you or anyone found a better solution, please let me know. I
am
fairly interested in this topic too.
>
Z.
fl*****@gmail.com
>
"PenguinPig" wrote:
>
>Dear All Experts
>>
>I would like to know how to convert a HTML into Image using C#. Or
allow
>me
>contains HTML code (parsed) in Image? I also tried this way but it just
>display the character "<" & ">" directly....
>>
>I have done googling, but all return shareware. I would like to know
how
>to
>programming...but not using shareware...
>>
>Thanks all.
>>
>>
>>
>>


Jul 17 '06 #6

P: n/a
Depending on the context, a WebBrowser Control could be used to do this. If
you create a Control that derives from the WebBrowser Control, you should be
able to override the OnPaint method and pass a Graphics instance to the base
class's OnPaint Method to get it to draw on an image.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.
"Zhenzhong Xu" <Zh*********@discussions.microsoft.comwrote in message
news:6F**********************************@microsof t.com...
>I did some research on this and i found a solution which is not
particularly
easy to implement, but it is doable.

if you want to do all these programatically, it is not easy.

First of all, you'll need to transform whatever Html you want to a new
xhtml
file/stream, (XHTML is a newer generation of html markup stated in XML).
Or
you can configure your ASP.Net application to render XHTML content.

Step 2: you'll need to transform XHTML to FO(formating object language)
using a XML Stylesheet (XSL transformation).

Step 3, Convert FO file/stream to a PDF file. You can achieve this step
by
using an opensource compiled dll called nfop which is hosted on
sourceforge.net.

Step 4. Convert PDF file/stream to an image file/stream. I am aware there
are some third party API out there for doing this step, but they are not
cheap unless you want to implement your own converter. You can probably
skip
this step if you can find an API to convert XSL-FOs to images directly.

So basically, here is the streamline process.

HTML ------->XHTML -----FO ---------PDF ------------JPEG
XSL NFOP Converter

Let me know if you have any questions.

Zhenzhong
fl*****@gmail.com

"PenguinPig" wrote:
>Dear Kevin

Then how can I capture this image? Which class I should use? Since I am
not
expert in this skill...
Thanks

"Kevin Spencer" <uc*@ftc.govwrote in message
news:u4**************@TK2MSFTNGP04.phx.gbl...
A browser does exactly what he wants. It converts HTML to an image,
which
is
painted on the Client rectangle of the browser.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

What You Seek Is What You Get.
"Zhenzhong Xu" <Zh*********@discussions.microsoft.comwrote in message
news:50**********************************@microsof t.com...
The closest solution i can think of is to use Office's COM object to
convert
html pages to word documents, and then convert the word documents to
JPEG(or
other image) files.

However if you or anyone found a better solution, please let me know.
I
am
fairly interested in this topic too.

Z.
fl*****@gmail.com

"PenguinPig" wrote:

Dear All Experts

I would like to know how to convert a HTML into Image using C#. Or
allow
>me
contains HTML code (parsed) in Image? I also tried this way but it
just
display the character "<" & ">" directly....

I have done googling, but all return shareware. I would like to know
how
>to
programming...but not using shareware...

Thanks all.




Jul 18 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.