Menu

#2 NewParagraph needs minwidth() method

closed-fixed
nobody
None
5
2009-02-09
2009-02-08
No

The Paragraph class in rl.NewParagraph does not override the minWidth() method. If such a paragraph is used in a table cell without explicit cellWidth (i.e. width is None or '*'), there is no reasonable minimum width for the paragraph. Therefore, reportlab tries to calculate the width from the font size of the cell and the str() value of the Paragraph. This gives wrong results, because the font size of the cell may not be the font size of the paragraph, and most of all, the str() value of the paragraph is not the raw text as in an ordinary paragraph.

A simple fix is to add the following method to the Paragraph class in rl.NewParagraph:

. def minWidth(self):
. """Attempt to determine a minimum sensible width"""
. return max([frag.width for frag in self.frags])

Discussion

  • H. von Bargen

    H. von Bargen - 2009-02-09
    • status: open --> closed-fixed
     
  • H. von Bargen

    H. von Bargen - 2009-02-09

    Added a minwidth method and a test case (see SVN repository).

     

Log in to post a comment.