[reportlab-users] Tried reportlab on python 3.4... failed

Glenn Linderman v+python at g.nevcal.com
Sat Oct 25 03:01:26 EDT 2014


Since reportlab was one of a very few reasons I have python 2.7 
installed, I have watched with anticipation the development of reportlab 
for python 3. Today I decided to try it, because I tried to operate on a 
file with a non-ASCII character in it, and python 2.7 doesn't like 
those, so rather than rename the file, I installed reportlab in Python 
3.4.1 via pip. The install seemed to go fine.

I tweaked the launching of my PDF generator to launch it via Python 
3.4.1 instead of python 2.7. Since it has been a while since I looked at 
that code, I figured I would get a bunch of Python 2->3 sort of errors, 
but... not yet...

Instead, on the call to mkdoc(), I got a traceback, from mkdoc() down 
here it is:

  in mkdoc:
     doc.build( elements, onFirstPage=mkpage )
   File 
"c:\python34\lib\site-packages\reportlab\platypus\doctemplate.py", line 
1127, in build
      BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
   File 
"c:\python34\lib\site-packages\reportlab\platypus\doctemplate.py", line 
8 90, in build
     self.handle_flowable(flowables)
   File 
"c:\python34\lib\site-packages\reportlab\platypus\doctemplate.py", line 
773, in handle_flowable
     if frame.add(f, canv, trySplit=self.allowSplitting):
   File "c:\python34\lib\site-packages\reportlab\platypus\frames.py", 
line 161, in _add
     w, h = flowable.wrap(aW, h)
   File "c:\python34\lib\site-packages\reportlab\platypus\paragraph.py", 
line 1035, in wrap
     blPara = self.breakLines([first_line_width, later_widths])
   File "c:\python34\lib\site-packages\reportlab\platypus\paragraph.py", 
line 1203, in breakLines
     splitLongWords = style.splitLongWords
AttributeError: 'MyParaSt' object has no attribute 'splitLongWords'


The definition for MyParaSt is as follows... works fine in reportlab 2.5 
on python 2.7....

class MyParaSt(PropertySet):
     defaults = {
         'fontName': 'Times-New-Roman',
         'fontSize': defsize,
         'leading': deflead,
         'leftIndent': 0,
         'rightIndent': 0,
         'firstLineIndent': 0,
         'alignment': TA_LEFT,
         'spaceBefore': 0,
         'spaceAfter': 0,
         'bulletFontName': 'Times-New-Roman',
         'bulletFontSize': 10,
         'bulletIndent': 0,
         'textColor': black,
         'backColor': None,
         'wordWrap': None,
         'borderWidth': 0,
         'borderPadding': 0,
         'borderColor': None,
         'borderRadius': None,
         'allowWidows': 1,
         'allowOrphans': 0,
         'textTransform': None,
             #uppercase lowercase (captitalize not yet) or None or absent
         }

I'm not exactly sure why I have a MyParaSt, since it has been a long 
time since I wrote this, but I would guess it might have been to set the 
default font(s)?  Maybe there would have been a better way, like only 
changing the items I wanted to change, rather than creating my whole new 
own defaults hash? I probably cut-n-pasted this idea from somewhere, 
though, and maybe it wasn't the best idea?

Where should I start reading? I did do a search and it seems 
splitLongWords is relatively new...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20141025/44ec1933/attachment.html>


More information about the reportlab-users mailing list