Hi,

I have managed to create a HTML file inside python code, now can someone help me to convert this to a PNG file through a Python script ??

I did Googling first but it resulted in various soft wares for above purpose which I don't want !!

I am not asking for direct solutions, but please give me directions if you can !!

This question is very unclear.
Python code and html is text and png is an image format.
So you can not convert this code to and image format off course.
Are you trying to make a fake png file with html and python code?

Thanks for replying :)

The html file which i managed to generate through python code, shows some figures when I open it through firefox. I want those figures in a png format ! What should I do to achieve this through python code ?

Kindly guide ..

What does the html code look like?

I've only done this once and used html2ps and then ps2png. I am pretty sure that convert within Imagemagick (located here in most distros file://localhost/usr/share/doc/ImageMagick-6.5.6/www/convert.html ) will do it in one step from the command line but you may have to supply additional paramenters like layers, etc.

Well, with some help from icky microsoft .net that is very possible with IronPython.
I'm afraid that's the only way to go.

Further description of the problem:

I have a python script which generates map-legends in the form of an html file. The legend generated have to be pasted on a map which is in a png format.

A png format file can be pasted on another png format file easily. But because the legends generated are in a html format I cannot paste it on the map file !!

Well, with some help from icky microsoft .net that is very possible with IronPython.
I'm afraid that's the only way to go.

Thanks for replying! I am working on Linux, so no Microsoft stuff allowed here.

I've only done this once and used html2ps and then ps2png. I am pretty sure that convert within Imagemagick (located here in most distros file://localhost/usr/share/doc/Image...w/convert.html ) will do it in one step from the command line but you may have to supply additional paramenters like layers, etc.

Thanks for replying! I did read about that stuff but I wanted to get it done through coding..

What does the html code look like?

Thanks for replying!
Here's my html code:

<div class="group">
<h1>Legend</h1>
<div class="group">
<h2>Areas</h2>
<div class="feature">
<img src="images/z15_1.png"/>
<div class="name">
City, Populated area
</div>
</div>
</div>
</div>
<div id="zoomLevel">Zoom level: 15</div>
<div id="scale">Scale: ~1:17000</div><div class="group">
<h1>Legend</h1>
<div class="group">
<h2>Areas</h2>
<div class="feature">
<img src="images/z15_1.png"/>
<div class="name">
City, Populated area
</div>
</div>
</div>
</div>
<div id="zoomLevel">Zoom level: 15</div>
<div id="scale">Scale: ~1:17000</div><div class="group">
<h1>Legend</h1>
<div class="group">
<h2>Areas</h2>
<div class="feature">
<img src="images/z15_1.png"/>
<div class="name">
City, Populated area
</div>
</div>
</div>
</div>
<div id="zoomLevel">Zoom level: 15</div>
<div id="scale">Scale: ~1:17000</div><div class="group">
<h1>Legend</h1>
<div class="group">
<h2>Areas</h2>
<div class="feature">
<img src="images/z15_1.png"/>
<div class="name">
City, Populated area
</div>
</div>
</div>
</div>
<div id="zoomLevel">Zoom level: 15</div>
<div id="scale">Scale: ~1:17000</div><div class="group">
<h1>Legend</h1>
<div class="group">
<h2>Areas</h2>
<div class="feature">
<img src="images/z15_1.png"/>
<div class="name">
City, Populated area
</div>
</div>
</div>
</div>
<div id="zoomLevel">Zoom level: 15</div>
<div id="scale">Scale: ~1:17000</div><div class="group">
<h1>Legend</h1>
<div class="group">
<h2>Areas</h2>
<div class="feature">
<img src="images/z15_1.png"/>
<div class="name">
City, Populated area
</div>
</div>
</div>
</div>
<div id="zoomLevel">Zoom level: 15</div>
<div id="scale">Scale: ~1:17000</div><div class="group">
<h1>Legend</h1>
<div class="group">
<h2>Areas</h2>
<div class="feature">
<img src="images/z15_1.png"/>
<div class="name">
City, Populated area
</div>
</div>
</div>
</div>
<div id="zoomLevel">Zoom level: 15</div>
<div id="scale">Scale: ~1:17000</div><div class="group">
<h1>Legend</h1>
<div class="group">
<h2>Areas</h2>
<div class="feature">
<img src="images/z15_1.png"/>
<div class="name">
City, Populated area
</div>
</div>
</div>
</div>
<div id="zoomLevel">Zoom level: 15</div>
<div id="scale">Scale: ~1:17000</div><div class="group">
<h1>Legend</h1>
<div class="group">
<h2>Areas</h2>
<div class="feature">
<img src="images/z15_1.png"/>
<div class="name">
City, Populated area
</div>
</div>
</div>
</div>
<div id="zoomLevel">Zoom level: 15</div>
<div id="scale">Scale: ~1:17000</div><div class="group">
<h1>Legend</h1>
<div class="group">
<h2>Areas</h2>
<div class="feature">
<img src="images/z15_1.png"/>
<div class="name">
City, Populated area
</div>
</div>
</div>
</div>
<div id="zoomLevel">Zoom level: 15</div>
<div id="scale">Scale: ~1:17000</div>

Kindly guide..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.