Wednesday, December 14, 2011

Using ReportLab to create a PDF from an image.

If you want to create a page in a PDF that contains an image that fills the entire page, here's a snippet that'll do exactly that. It requires PIL and ReportLab. Simply pass the function the path to an image and the canvas, and it'll fill the current page with the image (rotated properly including honoring EXIF orientation attributes).

Due to it handling EXIF orientation values, it's compatible with images taken from the camera of iPhone and iPad devices.

No comments:

Post a Comment