[reportlab-users] Paragraph, text and spaces

Tim Roberts timr at probo.com
Thu Jul 1 19:24:08 EDT 2010

Peter Milliken wrote:

> Still playing with reportlab :-)


> I am trying to print strings of text using Paragraph. These strings

> are lines of code listings so they include spaces to show indentation

> (spaces - not tabs). When I 'print' the document all of the spacing/

> indentation has been removed! i.e.

> ...

> "The following text creates an instance of the Paragraph class:

> Paragraph(text, style, bulletText=None)

> The text argument contains the text of the paragraph; excess white

> space is removed from the text at the

> ends and internally after linefeeds."


> I am more than happy with excess white space removed from the end of

> the line of text, but why am I seeing white space removed from the

> beginning?

Because that's white space that immediately follows a linefeed. The
mental model for Paragraph is similar to the HTML <p> tag, which does
the same kind of thing. The reason you use Paragraph is because you
want it to manage the spacing. If you want your text to be printed
without formatting, then you should use a Preformatted flowable, not a
Paragraph flowable. That's what it's for.

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

More information about the reportlab-users mailing list