[reportlab-users] Re: SimpleDocTemplate stripping internal whitespace??

Henning von Bargen reportlab-users@reportlab.com
Sat, 21 Feb 2004 14:38:47 +0100


Benjamin, what is it you want to do?
Have you read the manuals and did you look at the examples?
I suppose what you really want is a tabular layout.
Then you should use the Table class.
If you want preformatted text (it only makes sense with a fixed-width font
like Courier), then try using the Preformatted (sic!) class.
However I don't know of any reason to do so except printing source code
(using fixed-width fonts smells a bit like a report from the early 70ies).

Henning

> From: "Schollnick, Benjamin" <Benjamin.Schollnick@usa.xerox.com>
> To: "'reportlab-users@reportlab.com'" <reportlab-users@reportlab.com>
> Subject: [reportlab-users] SimpleDocTemplate stripping internal
whitespace??
> Reply-To: reportlab-users@reportlab.com
>
> Folks,
>
> I have run into a issue, that I can't explain....
>
> I use the follow routine, for Canvas.DrawString, without any
> problems...
>
> def format_lines    ( fieldname, data, fieldname_width=15, data_width=20):
>     """
>         Reformat the data into a string.
>         Simply a "Macro", to reduce duplication.
>
>         Inputs -
>             FieldName   - Name of the field that is to be reformated.
>             data        - The actual stored data.
>
>         Outputs -
>             fieldname = "This is the fieldname"
>             data      = "This is the data."
>             "This is the fie: This is the "
>
>         Example:
>
>     """
>     fmt = '  %-' + str(fieldname_width) + 's: %-' + str(data_width) + 's'
>     return fmt % (fieldname, data)
>
>
> Now since I decided to use SimpleDocTemplate, it is appearing that
> the
> internal whitespace is being removed...
>
> i.e.
>
> Version : 1.7h
>
> Is there a simple way to have it not filter the internal white
> space?
>
>         Contents.append (Paragraph ( format_lines    ( entry[1],
> data[entry[2]],
>                                                       fieldname_width=25,
> data_width=20),
>                                      normal ) )
>
>
> - Ben