[reportlab-users] WordCount in reportlab paragraph
Robin Becker
robin at reportlab.com
Fri Feb 27 10:22:59 EST 2009
Andy Robinson wrote:
> 2009/2/27 Robin Becker <robin at reportlab.com>:
>> Harald, thanks for the report. Unfortunately I think the problem lies
>> elsewhere
> ...
Harald, I think the(at least my) problem can be fixed with this patch; can you
try it out?
Index: /code/reportlab/platypus/paragraph.py
===================================================================
--- /code/reportlab/platypus/paragraph.py (revision 3441)
+++ /code/reportlab/platypus/paragraph.py (working copy)
@@ -1118,9 +1118,11 @@
if nText!='' and nText[0]!=' ':
g.text += ' ' + nText
+ ni = 0
for i in w[2:]:
g = i[0].clone()
g.text=i[1]
+ if g.text: ni = 1
words.append(g)
fontSize = g.fontSize
if calcBounds:
@@ -1134,6 +1136,7 @@
maxSize = max(maxSize,fontSize)
maxAscent = max(maxAscent,ascent)
minDescent = min(minDescent,descent)
+ if not nText and ni: n+=1
currentWidth = newWidth
else: #either it won't fit, or it's a lineBreak tag
>
> This kind of problem is eminently suited to unit tests, when
when the unit test framework can look at our pdfs and see that a word is not
properly aligned then I'll give in. We could try saving images of these problems
(say using ghost script) and then compare images.
> you have them. Harald, could you spare us a paragraph
> of super-long German insurance words for a test case without
> violating client confidentiality? It would be more fun!
>
> - Andy
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
--
Robin Becker
More information about the reportlab-users
mailing list