2

I'm using Google App Engine with Python.

I would like to know how to convert a pdf file into different jpeg images (one for each page). Is it possible?

I found an opensource pdf library: reportlab but it looks like they don't have such a feature in their API. Am I wrong?

Thanks in advance

Damien
  • 439
  • 5
  • 16

1 Answers1

-1

You want a library called PythonMagick, which can be found here.

James Brewer
  • 255
  • 1
  • 3
  • 6
  • I took a look at it and have several additional questions: 1) is it possible to use this library with App Engine: these files are mostly written in C and I can't compile anything on App Engine. What should I do to make it work? 2) What is the function I need? Is it the one in the file _CompressionType.cpp? – Damien Jul 26 '11 at 12:24
  • It won't work, because it's a C++ library. You could try to extract the text and then create your images using pure Python libraries. See, for example, [PDFMiner](http://www.unixuser.org/~euske/python/pdfminer/index.html) and [PyPNG](http://packages.python.org/pypng/). – Paolo Moretti Jul 26 '11 at 12:36
  • Paolo, actually I would need something closer to "a screenshot". I need both the text, the images and all the content within each page of the pdf. My jpeg images must be the exact copy of each pdf page (I mean visually). – Damien Jul 26 '11 at 12:49
  • 4
    @Damien, I'm afraid you can't do it. Usually this can be easily done with GhostScript and ImageMagick, but sadly you can't use them on App Engine. See [this discussion](http://groups.google.com/group/google-appengine/browse_thread/thread/50c55974d7af3618) for more details. Probably the best solution is to use an external service. Google Docs Viewer, for example, already serves PNG rendition of every uploaded pdf. – Paolo Moretti Jul 26 '11 at 14:44
  • @Paolo Thanks. Indeed I just read the Google Docs API could allow me to convert a PDF or PPT to a PNG file. Maybe that's the solution I should implement even if it looks a little complex (in my architecture)... – Damien Jul 26 '11 at 15:52
  • @Paolo Maybe you could write an answer so that I can close out this topic. Thanks – Damien Jul 27 '11 at 20:31