Problem Creating NewLines in PDF

MRAB python at mrabarnett.plus.com
Wed Aug 18 13:10:23 EDT 2010


Andrew Evans wrote:
> Hello I am generating a PDF in web2py but its ignoring my line breaks.
> 
>  randname = random.randrange(1, 10001)
>         styles = getSampleStyleSheet()
>         title = "My Title"
>         doc = SimpleDocTemplate("primer.pdf")
>         story = []
>         story.append(Paragraph(strftime("%a, %d %b %Y %H:%M:%S", 
> gmtime()),styles["Heading2"]))
>         para = ParagraphStyle(name="output", fontName='Helvetica', 
> fontSize=12)
>         story.append(Paragraph(str(result_list), para))

str(result_list) is converting the list into a string. Did you mean to
do that?

>         doc.build(story)
>         response.headers['Content-Type']='application/pdf'
>         response.headers['Content-Disposition'] = 
> 'attachment;filename='+str(randname)+'-.pdf'
>         return response.stream(open("primer.pdf", 'rb'))
> 
> 
> result_list is a generated list. The pdf ignores line breaks and outputs 
> it as a list so ['  '] are included also. Any idea how I can create line 
> breaks and get rid of the ['  ']
>  




More information about the Python-list mailing list