Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

python - Reportlab - how to introduce line break if the paragraph is too long for a line

I have a list of text to be added to a reportlab frame

style = getSampleStyleSheet()['Normal']
style.wordWrap = 'LTR'
style.leading = 12
for legend in legends:
    elements.append(Paragraph(str(legend),style))

If the legend is too long, the text at the end is not visible at all. How to introduce line breaks in this situation.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

This may or may not apply but I just learned that which I normally use to introduce new lines in Python strings gets ignored by the Paragraph object of ReportLab.

From a mailing list I learned that inside Paragraph you can use HTML's <br/> to introduce the new line instead.

That works well for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share

755k questions

754k answers

5 comments

53.3k users

...