convert pdf to png

Rob Wolfe rw at smsnet.pl
Tue Dec 25 12:36:06 EST 2007


Carl K <carl at personnelware.com> writes:

> I need to take the take the pdf output from reportlab and create a
> preview image for a web page.  so png or something.  I am sure
> ghostscript will be involved. I am guessing PIL or ImageMagic ?
>
> all sugestions welcome.

Did you try to use `reportPM` from rl_addons [1]_? 
This is an extension of the reportlab package.

There is also PIL needed and on my linux box
I needed some additional fonts [2]_.

And then I could create PNG directly from reportlab, e.g:

<code>
from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics import renderPM

d = Drawing(400, 200)
d.add(String(150, 100, 'Hello World', fontSize=18))
renderPM.drawToFile(d, 'test.png', 'PNG')
</code>

.. [1] http://www.reportlab.co.uk/svn/public/reportlab/trunk/rl_addons/
.. [2] http://www.reportlab.com/ftp/fonts/pfbfer.zip

HTH,
Rob



More information about the Python-list mailing list