[reportlab-users] SimpleDocTemplate Margin Problems

Lucas Howell thingfu at gmail.com
Tue Jun 23 20:50:20 EDT 2009


Hi All,

I'm having a problem when using the SimpleDocTemplate with Paragraphs
that cause an unpredictable margin.

Basically I specify a margin of 0.5 inches in the Template and it
works just fine when Table Flowables are added to the Story, but when
I add Paragraphs (with leftIndent=0 specified) the margin is like 0.6
inches or more. Thus my various flowables don't line up on page
(paragraphs have some extra mysterious indentation). There's got to
be some extra padding or something in the SimpleDocTemplate or
Paragraphs that I don't know about, but everything is zeroed out, so
it doesn't make sense.

Some example code is below:

---------------------------------
response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attachment; filename=example.pdf;'

doc = SimpleDocTemplate(filename=response,
pagesize=letter,
topMargin=0.5*inch,
bottomMargin=0.5*inch,
leftMargin=0.5*inch,
rightMargin=0.5*inch)

my_paragraph_style =
ParagraphStyle(name='my_paragraph_style',fontName='Helvetica',

fontSize=11,leading=12,spaceBefore=0,leftIndent=0)
p1 = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed egestas'
Story = []
Story.append(Paragraph(p1,my_paragraph_style))
doc.build(Story, onFirstPage=myFirstPage,onLaterPages=myLaterPages)
return response
---------------------------------

This code results in a PDF with the paragraph having roughly a 0.6in
margin instead of a 0.5inch margin.

Any responses would be appreciated! I've looked through all the
documentation and can't find any explanation for this "extra" margin /
padding that shows up and causes my alignment to be off.

Thanks,

Lucas


More information about the reportlab-users mailing list