From 336cd588e66007f938a939b0b0e6b01bb407ce29 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Fri, 22 Jun 2007 13:18:49 +0000 Subject: [PATCH] 0001055: Pictures of the gallery are not used in the detailed ancestor's report when output format is PDF svn: r8625 --- ChangeLog | 4 ++++ src/docgen/PdfDoc.py | 28 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ef921f71..2cb7f5dc3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-06-22 Brian Matherly + * src/docgen/Pdfdoc.py: 0001055: Pictures of the gallery are not used in the + detailed ancestor's report when output format is PDF + 2007-06-20 Don Allingham * src/DbManager.py: Catch the icons properly * src/GrampsDb/_GrampsDBDir.py: catch error on lock file deletion diff --git a/src/docgen/PdfDoc.py b/src/docgen/PdfDoc.py index ad8f8ff7a..c2955511c 100644 --- a/src/docgen/PdfDoc.py +++ b/src/docgen/PdfDoc.py @@ -36,6 +36,7 @@ from gettext import gettext as _ import BaseDoc from PluginUtils import register_text_doc, register_draw_doc, register_book_doc import Errors +from QuestionDialog import ErrorDialog import ImgManip import Mime @@ -100,6 +101,9 @@ if version_tuple < (2,0): else: enc = pass_through +# Only announce PIL warning once per use of Gramps +_pil_warn = True + #------------------------------------------------------------------------ # # GrampsDocTemplate @@ -342,14 +346,11 @@ class PdfDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc,BaseDoc.DrawDoc): def add_media_object(self,name,pos,x_cm,y_cm): try: - img = ImgManip.ImgManip(nname) + img = ImgManip.ImgManip(name) except: return x,y = img.size() - - if (x,y) == (0,0): - return if (x,y) == (0,0): return @@ -363,7 +364,24 @@ class PdfDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc,BaseDoc.DrawDoc): act_height = y_cm act_width = x_cm/ratio - im = Image(str(name),act_width*cm,act_height*cm) + try: + # Reportlab uses PIL to layout images. Make sure it is installed. + import PIL + except: + global _pil_warn + if _pil_warn: + ErrorDialog( + _("You do not have the Python Imaging Library installed " + "Images will not be added to this report")) + _pil_warn = False + return + + try: + im = Image(str(name),act_width*cm,act_height*cm) + except: + ErrorDialog( _("Reportlab is unable to add this image: %s") % name ) + return + if pos in ['left','right','center']: im.hAlign = pos.upper() else: