Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Silverlight5
Hi All,
I have a challenge, I have to convert an html page, which is hosted on the server to png.
I have gone through many websites. They all are providing solution for windows based application.
 
Any help will be appreciated.
 

Thanks
Posted 7-Dec-12 1:20am
Comments
Sergey Alexandrovich Kryukov at 7-Dec-12 15:17pm
   
Why?!
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I assume, you want to save on client side some sort of formatted text as image. There are ways to do that, but I suggest you do it on server side, and send it to the client as content. First of all, because you have more possibilities in a server os than in silverlight. And the content is also on the server, as you stated.
On server side you can call any tool, even IE - but that's complicated. You can simply spawn a process and call a command line tool that generates the image for you. If this could last long time, you might use some async callback to the client (but there are other options too). I have not found any free cli tools for windows, but commercial ones (http://www.coolutils.com/HTML-PNG-CommandLine[^] or http://www.verypdf.com/app/html-to-any/index.html[^]).
But you can also make your own tool (or no tool, just generate the image), starting from this great article: A Professional HTML Renderer You Will Use[^].
  Permalink  
Comments
Gyandeep neema at 7-Dec-12 23:29pm
   
Thanks Zoltan,
I have tried this I mean I tried to convert html content into png on server. It works fine but the problem is Bitmap class.
WCF doesn't support WriteableBitmap and Silverlight doesn't support Bitmap.
Will you be able to suggest any other class which is supported by both.
Zoltán Zörgő at 8-Dec-12 13:45pm
   
But let's clarify: you want to let the user save this content from your silverligth client, or you want to display this content in the silverlight applet?
First case: check this out http://www.silverlightshow.net/items/Uploading-and-downloading-images-from-WCF-in-Silverlight.aspx (download part). Second case, this might help: http://www.dotnetcurry.com/ShowArticle.aspx?ID=220
Gyandeep neema at 9-Dec-12 23:22pm
   
Thanks Zoltan,
My ultimate goal is like I have a graph, which is generating by a third party tool. Those graphs will be hosted on the server. Now my problem is when I display this graph in silverlight HtmlHost, It sits on the whole application and it overlaps some of my app contents. So I want to create a png and display in an image control.
Zoltán Zörgő at 10-Dec-12 12:32pm
   
First of all, can you get this "third party tool" to output the graph in a png (or to i't standard output)? Or do you know any other way to get the graphical content as any kind of graphics from it?
Gyandeep neema at 10-Dec-12 23:17pm
   
No it gives standard output and I don't have any other option. The only option i have is to convert the HTML to png on server side and get the output through WCF.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

There is no one "predefined" way to "convert" HTML to PNG, because the concepts are completely different.
 
HTML document does not have certain size and shape, its appearance depends on several factors like rendering engine, predefined styles depending on user preferences (it's rare that all styles are comprehensively described with CSS), and, most importantly, in the size of the browser windows used to view the page. In contrast, PNG is the bitmap with fixed size of the image in pixels.
 
If you explain your ultimate goals, you can get exact advice on what to do instead.
 
—SA
  Permalink  
Comments
Gyandeep neema at 7-Dec-12 23:25pm
   
Thanks Sergey for you reply.
My ultimate goal is like I have a graph, which is generating by a third party tool. Those graphs will be hosted on the server. Now my problem is when I display this graph in silverlight HtmlHost, It sits on the whole application and it overlaps some of my app contents. So I want to create a png and display in an image control.
Sergey Alexandrovich Kryukov at 8-Dec-12 0:14am
   
If this is Silverlight graphics, it has nothing to do with HTML content. I don't really understand the problem because you did not completely describe it, but why can't you use original graphics generated by this tool, whatever it is? It it overlaps, you should try to change the layout, instead of loosing data, which always happens when you render some graphical data in a bitmap.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 386
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 215
3 /\jmot 189
4 Praneet Nadkar 173
0 OriginalGriff 8,289
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,624
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100