convert pdf to png

Boris Borcic bborcic at gmail.com
Wed Dec 26 08:29:44 EST 2007


Carl K wrote:
> Rob Wolfe wrote:
>> 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
> 
> This sounds like what I was looking for.  some how this got missed when 
> I poked around reportlab land.
> 
> Thanks much.
> 
> Carl K

Beware... AFAIK this is only a backend for reportlab graphics drawings, IOW it 
will render drawings and charts from the reportlab.graphics package but will not 
render reportlab pdf canvas.




More information about the Python-list mailing list