Basically what I am doing right now as a workaround is I wrote a
function to parse/wrap the value before printing it out. Anyone else
have a better solution please do let me know.

def preformat_html_textarea(value,endwidth=135):
    ''' since reportlab doesn't provide a way to keep the <pre> of
what ever
        is entered in the html textarea. This is manual way to text
wrap.
    '''
    import textwrap
    new_value = value.replace('\r','')
    new_values = new_value.split('\n')
    result = ""
    for line in new_values:
        result += textwrap.fill(line,endwidth) + "\n"

    return result


Thusjanthan


On Jul 8, 11:53 am, thusjanthan <thusjant...@gmail.com> wrote:
> Hi,
>
> I have a user that enters some formatted text in a html textarea. I
> would like to use reportlab to display that and other fields in a PDF.
> However when I wrap the text in a Paragraph type it alters the
> formatting. Can anyone suggest how to keep the formatting that the
> user enters into the textarea such as spaces and new lines etc.
>
> Example:
>
> objectives:
> Hi
>
> My name is blah etc..
>
> endcontent
>
> PythonCode:
>
> Story.append(Paragraph("%s" % objectives,styles['NormalIndent']))
>
> However the pdf outputs this as all clumped together like: "Hi My name
> is blah etc.. endcontent"
>
> Any thoughts?
>
> Cheers,
> Nathan.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to