0

I'm generating some pdf's with Reportlab and Django using a web interface. The pdf's are always going to be a single page. I'd like to generate a png or jpg image of the generated page and return that to the browser for the user to preview before saving the final pdf and delivering it to the end user. Is there anyway to do this?

Geuis
  • 41,122
  • 56
  • 157
  • 219

1 Answers1

0

This answer explains that you can use ghostscript to convert pdf to png. Depending of the requirements of your app (traffic, response time, nb of pdfs ...) it may or may not be a solution for you.

This is just an idea, but may be you can generate the preview image in parallel using PIL ImageDraw and get rid of the pdf-to-png conversion.

I hope it helps

Community
  • 1
  • 1
luc
  • 41,928
  • 25
  • 127
  • 172
  • Sadly PIL's support of TTF fonts in combination with image creation is very buggy. This comes from spending over 20 hours trying to work around memory leaks and inconsistent handling of identical text and fonts literally from one image generation to the next. Thanks for the ghostscript reference. I'll check it out. – Geuis Nov 08 '10 at 08:32