[reportlab-users] Handling Ragged Lines in reportlab

Tim Roberts timr at probo.com
Thu Aug 13 13:56:40 EDT 2015


Kaviraj Kanagaraj wrote:
>
> I am using reportlab to generate pdf with text and images. I am facing
> problem when using Paragraph in reportlab. Im using center alignment.
> But I see some paragraph have one or two words at the last line of the
> paragraph which is not pleasing visually. I have explored about the
> problem and found that I need to handle ragged lines. There is an
> option called "Balance ragged line" in InDesign. What is the
> appropriate option to be used in reportlab? Help me in figuring it out.

There is no built-in function do this.  You're talking about a rather
complicated, iterative process here.  I can imagine an implementation
that just re-runs the line breaking process iteratively, reducing the
right margin a tiny bit each time, until the last line is closer to
being full, but you'd have to settle on heuristics.  How full is full
enough?  How much is too full?  Is it OK to add another line?  I suppose
you could create a derivative of Paragraph that does this, by wrapping
breakLines.


> P.S: I have raised an issue on reportlab repo and also posted a
> question in google groups but sadly no response.

What Google group did you use?  As far as I know, this is the only
mailing list for official and peer support.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20150813/19222975/attachment.html>


More information about the reportlab-users mailing list