tags:

views:

373

answers:

5

Hi,

I'm working on a project which takes some images from user and then creates a PDF file which contains all of these images.

Is there any way or any tool to do this in Python? E.g. to create a PDF file (or eps, ps) from image1 + image 2 + image 3 -> PDF file?

+5  A: 

See http://www.reportlab.com/

The toolkit is in Python (the opensource-link *)

Blauohr
@Blauohr, a better link might be http://www.reportlab.com/software/opensource/ as you were probably recommending the open source package as the place to start, not the commercial one.
Peter Hansen
Changed to the opensource-link / thanks to Peter
Blauohr
+1 for Reportlab. I haven't used any of it's image capabilities but I did for a project to split up massive text files into PDFs and it was a huge timesaver. While going through the docs I glanced at the image stuff and it didn't seem too bad.
Tofystedeth
A: 

You can try this or you can try PyQt, which has support for printing to pdf.

gruszczy
+1  A: 

I suggest pyPdf. It works really nice. I also wrote a blog post some while ago, you can find it here. HTH.

Geo
+1 for mention pyPdf
Blauohr
A: 

It depends on what format your image files are in, but for a project here at work I used the tiff2pdf tool in LibTIFF from RemoteSensing.org. Basically just used subprocess to call tiff2pdf.exe with the appropriate argument to read the kind of tiff I had and output the kind of pdf I wanted. If they aren't tiffs you could probably convert them to tiffs using PIL, or maybe find a tool more specific to your image type (or more generic if the images will be diverse) like ReportLab mentioned above.

Tofystedeth
+1  A: 

I have done this quite a bit in PyQt and it works very well. Qt has extensive support for images, fonts, styles, etc and all of those can be written out to pdf documents.

Allen
+1 for Qt in general, especially after they open sourced it.
Paul Hildebrandt