[reportlab-users] Adding text to frames

William Chipman bill at chipmaninfo.com
Mon Oct 22 16:29:08 EDT 2018


In the following python code, I have set up 5 frames on a page.
When I add more than one line of text to a frame, the text just overlays.
How do you get the line to advance?
     bc

from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch
from reportlab.platypus import Paragraph, Frame
styles = getSampleStyleSheet()
stylesC = styles['Code']
stylesC.__setattr__('fontName', 'Courier')
stylesC.__setattr__('fontSize', 12)
stylesC.__setattr__('leading', 0)

story1 = []
story1.append(Paragraph('Story 1', stylesC))
story2 = []
story2.append(Paragraph('Story 2', stylesC))
story3 = []
story3.append(Paragraph('Story 3', stylesC))
story4 = []
story4.append(Paragraph('Story 4', stylesC))
story4.append(Paragraph('Story 4a', stylesC))
story4.append(Paragraph('Story 4b', stylesC))
story5 = []
story5.append(Paragraph('Story 5', stylesC))
story6 = []
story6.append(Paragraph('Story 6', stylesC))
c = Canvas('test9.pdf')
f1 = Frame(0, 1 * inch, 1.5*inch, 9.5*inch,
showBoundary=1,leftPadding=0,bottomPadding=0,rightPadding=0,topPadding=0)
f2 = Frame(1.5* inch, 7*inch, 1.5*inch, 3.5*inch,
showBoundary=1,leftPadding=0,bottomPadding=0,rightPadding=0,topPadding=0)
f3 = Frame(3*inch, 7*inch, 1.5*inch, 3.5*inch,
showBoundary=1,leftPadding=0,bottomPadding=0,rightPadding=0,topPadding=0)
f4 = Frame(4.5*inch, 8.5*inch, 2.5*inch, 2*inch,
showBoundary=1,leftPadding=0,bottomPadding=0,rightPadding=0,topPadding=0)
f5 = Frame(4.5*inch, 7*inch, 2.5*inch, 1.5*inch,
showBoundary=1,leftPadding=0,bottomPadding=0,rightPadding=0,topPadding=0)
f6 = Frame(1.5*inch,  1 * inch, 5.5*inch, 6*inch,
showBoundary=1,leftPadding=0,bottomPadding=0,rightPadding=0,topPadding=0)

f1.addFromList(story1, c)
f2.addFromList(story2, c)
f3.addFromList(story3, c)
f4.addFromList(story4, c)
f5.addFromList(story5, c)
f6.addFromList(story6, c)

c.save()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20181022/56685817/attachment.html>


More information about the reportlab-users mailing list