PC Review


Reply
Thread Tools Rate Thread

Convert HTML to Image

 
 
PenguinPig
Guest
Posts: n/a
 
      13th Jul 2006
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.



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Wmhlbnpob25nIFh1?=
Guest
Posts: n/a
 
      13th Jul 2006
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 Removed)

"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.
>
>
>
>

 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      14th Jul 2006
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" <(E-Mail Removed)> wrote in message
news:506CD853-BEFD-4C5A-A7BE-(E-Mail Removed)...
> 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 Removed)
>
> "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.
>>
>>
>>
>>



 
Reply With Quote
 
PenguinPig
Guest
Posts: n/a
 
      15th Jul 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail 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.
>
>
> "Zhenzhong Xu" <(E-Mail Removed)> wrote in message
> news:506CD853-BEFD-4C5A-A7BE-(E-Mail Removed)...
> > 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 Removed)
> >
> > "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.
> >>
> >>
> >>
> >>

>
>



 
Reply With Quote
 
=?Utf-8?B?Wmhlbnpob25nIFh1?=
Guest
Posts: n/a
 
      17th Jul 2006
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 Removed)

"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" <(E-Mail Removed)> wrote in message
> news:(E-Mail 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.
> >
> >
> > "Zhenzhong Xu" <(E-Mail Removed)> wrote in message
> > news:506CD853-BEFD-4C5A-A7BE-(E-Mail Removed)...
> > > 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 Removed)
> > >
> > > "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.
> > >>
> > >>
> > >>
> > >>

> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?Wmhlbnpob25nIFh1?=
Guest
Posts: n/a
 
      17th Jul 2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail 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.
> >
> >
> > "Zhenzhong Xu" <(E-Mail Removed)> wrote in message
> > news:506CD853-BEFD-4C5A-A7BE-(E-Mail Removed)...
> > > 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 Removed)
> > >
> > > "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.
> > >>
> > >>
> > >>
> > >>

> >
> >

>
>
>

 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      18th Jul 2006
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" <(E-Mail Removed)> wrote in message
news:6FAD983D-8C19-4547-B1D8-(E-Mail Removed)...
>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 Removed)
>
> "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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail 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.
>> >
>> >
>> > "Zhenzhong Xu" <(E-Mail Removed)> wrote in message
>> > news:506CD853-BEFD-4C5A-A7BE-(E-Mail Removed)...
>> > > 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 Removed)
>> > >
>> > > "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.
>> > >>
>> > >>
>> > >>
>> > >>
>> >
>> >

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert HTML to Image Format M. Meganathan Microsoft Dot NET Compact Framework 0 6th Aug 2009 01:20 PM
How do I convert an HTML to a image? Carol Green Microsoft Powerpoint 3 17th Jun 2009 02:35 AM
Convert html to jpeg, tiff, gif and png with Html To Image Zhao Sheng Microsoft C# .NET 0 9th Oct 2004 12:31 PM
Convert HTML To Image Tiraman :-\) Microsoft VB .NET 7 9th Oct 2004 11:28 AM
HELP! Need to convert HTML Page To image Chad A. Beckner Microsoft C# .NET 5 6th Aug 2004 04:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:43 PM.