diff --git a/README b/README index 7bcc14378..a07f58980 100644 --- a/README +++ b/README @@ -38,6 +38,9 @@ The following packages are optional enchant. A version of gtkspell with gobject introspection is needed, so minimally version 3.0.0 + PIL Python Image Library is needed to convert non jpg images to + jpg so as to include them in LaTeX output + ttf-freefont More font support in the reports gir-webkit GObject introspection data of WebKit is required for the diff --git a/gramps/plugins/docgen/latexdoc.py b/gramps/plugins/docgen/latexdoc.py index 24bba64f0..962838f1c 100644 --- a/gramps/plugins/docgen/latexdoc.py +++ b/gramps/plugins/docgen/latexdoc.py @@ -40,6 +40,8 @@ from gramps.gen.ggettext import gettext as _ from bisect import bisect import re, os, sys +import logging +_LOG = logging.getLogger(".latexdoc") #----------------------------------------------------------------------- - # @@ -48,7 +50,14 @@ import re, os, sys #------------------------------------------------------------------------ from gramps.gen.plug.docgen import BaseDoc, TextDoc, PAPER_LANDSCAPE, FONT_SANS_SERIF, URL_PATTERN from gramps.gen.plug.docbackend import DocBackend -import Image +HAVE_PIL = False +try: + from PIL import Image + HAVE_PIL = True +except: + _LOG.warning( + _('No PIL Image installed for your python version, cannot produce jpg ' + 'images from non-jpg images in LaTex Documents')) _CLICKABLE = r'''\url{\1}''' @@ -1203,7 +1212,9 @@ class LaTeXDoc(BaseDoc, TextDoc): outfile = os.path.splitext(infile)[0] pictname = latexescape(os.path.split(outfile)[1]) outfile = ''.join((outfile, '.jpg')) - if infile != outfile: + outfile2 = ''.join((outfile, '.jpeg')) + outfile3 = ''.join((outfile, '.png')) + if HAVE_PIL and infile not in [outfile, outfile2, outfile3] : try: curr_img = Image.open(infile) curr_img.save(outfile) @@ -1214,6 +1225,11 @@ class LaTeXDoc(BaseDoc, TextDoc): self.emit(''.join(('%\n *** Error: cannot convert ', infile, '\n *** to ', outfile, '%\n'))) + elif not HAVE_PIL: + self.emit(''.join(('%\n *** Error: cannot convert ', infile, + '\n *** to ', outfile, + 'PIL not installed %\n'))) + if self.in_table: self.pict_in_table = True @@ -1222,7 +1238,6 @@ class LaTeXDoc(BaseDoc, TextDoc): self.pict_width = x self.pict_height = y - def write_text(self,text,mark=None,links=False): """Write the text to the file""" if text == '\n': diff --git a/gramps/plugins/docgen/rtfdoc.py b/gramps/plugins/docgen/rtfdoc.py index 3a5e98681..66c24dc14 100644 --- a/gramps/plugins/docgen/rtfdoc.py +++ b/gramps/plugins/docgen/rtfdoc.py @@ -295,7 +295,7 @@ class RTFDoc(BaseDoc,TextDoc): self.text += '}' def start_superscript(self): - self.text += '{{\*\updnprop5801}\up10 ' + self.text += '{{\\*\\updnprop5801}\\up10 ' def end_superscript(self): self.text += '}'