Convert HTML to Image

  • Thread starter Thread starter PenguinPig
  • Start date Start date
P

PenguinPig

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.
 
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.
(e-mail address removed)
 
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.
 
Dear Kevin

Then how can I capture this image? Which class I should use? Since I am not
expert in this skill...
Thanks
 
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
(e-mail address removed)
 
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.
 
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.
 

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

Back
Top