Python PDF thumbnail preview generation

linux, macos, pdf-generation, python

Solution

You can use ImageMagick {apt-get install imagemagick on Ubuntu} (it also has Python lib PythonMagick) to convert pdf to images

import subprocess
params = ['convert', 'pdf_file', 'thumb.jpg']
subprocess.check_call(params)

You can also provide parameters at which the image has to generate out of the pdf like

params = ['convert', '-density 300 -resize 220x205', 'pdf_file', 'thumb.jpg']
subprocess.check_call(params)

Problem

I am looking for ways to generate jpeg thumbnail of pdf files. I would like to do that in Python. Is there any library or can anyone guide me how to do it? Thanks I am working on MacOS X Lion. But I would like to run it on Ubuntu or CentOS.

Original source

Related problems