Connecting Tech Pros Worldwide Forums | Help | Site Map

Convert HTML to Image

PenguinPig
Guest
 
Posts: n/a
#1: Jul 13 '06
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.




Zhenzhong Xu
Guest
 
Posts: n/a
#2: Jul 13 '06

re: Convert HTML to Image


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.
flyfree@gmail.com

"PenguinPig" wrote:
Quote:
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.
>
>
>
>
Kevin Spencer
Guest
 
Posts: n/a
#3: Jul 14 '06

re: Convert HTML to Image


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" <ZhenzhongXu@discussions.microsoft.comwrote in message
news:506CD853-BEFD-4C5A-A7BE-87780A2BDCD1@microsoft.com...
Quote:
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.
flyfree@gmail.com
>
"PenguinPig" wrote:
>
Quote:
>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.
>>
>>
>>
>>

PenguinPig
Guest
 
Posts: n/a
#4: Jul 15 '06

re: Convert HTML to Image


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" <uce@ftc.govwrote in message
news:u4emkSzpGHA.4216@TK2MSFTNGP04.phx.gbl...
Quote:
A browser does exactly what he wants. It converts HTML to an image, which
is
Quote:
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" <ZhenzhongXu@discussions.microsoft.comwrote in message
news:506CD853-BEFD-4C5A-A7BE-87780A2BDCD1@microsoft.com...
Quote:
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
Quote:
Quote:
fairly interested in this topic too.

Z.
flyfree@gmail.com

"PenguinPig" wrote:
Quote:
Dear All Experts
>
I would like to know how to convert a HTML into Image using C#. Or
allow
Quote:
Quote:
Quote:
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
Quote:
Quote:
Quote:
to
programming...but not using shareware...
>
Thanks all.
>
>
>
>
>
>

Zhenzhong Xu
Guest
 
Posts: n/a
#5: Jul 17 '06

re: Convert HTML to Image


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
flyfree@gmail.com

"PenguinPig" wrote:
Quote:
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" <uce@ftc.govwrote in message
news:u4emkSzpGHA.4216@TK2MSFTNGP04.phx.gbl...
Quote:
A browser does exactly what he wants. It converts HTML to an image, which
is
Quote:
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" <ZhenzhongXu@discussions.microsoft.comwrote in message
news:506CD853-BEFD-4C5A-A7BE-87780A2BDCD1@microsoft.com...
Quote:
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
Quote:
Quote:
fairly interested in this topic too.
>
Z.
flyfree@gmail.com
>
"PenguinPig" wrote:
>
>Dear All Experts
>>
>I would like to know how to convert a HTML into Image using C#. Or
allow
Quote:
Quote:
>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
Quote:
Quote:
>to
>programming...but not using shareware...
>>
>Thanks all.
>>
>>
>>
>>
>
>
>
Zhenzhong Xu
Guest
 
Posts: n/a
#6: Jul 17 '06

re: Convert HTML to Image


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:
Quote:
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" <uce@ftc.govwrote in message
news:u4emkSzpGHA.4216@TK2MSFTNGP04.phx.gbl...
Quote:
A browser does exactly what he wants. It converts HTML to an image, which
is
Quote:
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" <ZhenzhongXu@discussions.microsoft.comwrote in message
news:506CD853-BEFD-4C5A-A7BE-87780A2BDCD1@microsoft.com...
Quote:
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
Quote:
Quote:
fairly interested in this topic too.
>
Z.
flyfree@gmail.com
>
"PenguinPig" wrote:
>
>Dear All Experts
>>
>I would like to know how to convert a HTML into Image using C#. Or
allow
Quote:
Quote:
>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
Quote:
Quote:
>to
>programming...but not using shareware...
>>
>Thanks all.
>>
>>
>>
>>
>
>
>
Kevin Spencer
Guest
 
Posts: n/a
#7: Jul 18 '06

re: Convert HTML to Image


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" <ZhenzhongXu@discussions.microsoft.comwrote in message
news:6FAD983D-8C19-4547-B1D8-BBD8A7EADC7C@microsoft.com...
Quote:
>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
flyfree@gmail.com
>
"PenguinPig" wrote:
>
Quote:
>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" <uce@ftc.govwrote in message
>news:u4emkSzpGHA.4216@TK2MSFTNGP04.phx.gbl...
Quote:
A browser does exactly what he wants. It converts HTML to an image,
which
>is
Quote:
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" <ZhenzhongXu@discussions.microsoft.comwrote in message
news:506CD853-BEFD-4C5A-A7BE-87780A2BDCD1@microsoft.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
Quote:
fairly interested in this topic too.
>
Z.
flyfree@gmail.com
>
"PenguinPig" wrote:
>
>Dear All Experts
>>
>I would like to know how to convert a HTML into Image using C#. Or
>allow
Quote:
>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
Quote:
>to
>programming...but not using shareware...
>>
>Thanks all.
>>
>>
>>
>>
>
>
>>
>>
>>

Closed Thread