Reportlab - 如果段落对于一行来说太长,如何引入换行符
我有一个要添加到reportlab框架中的文本列表
style = getSampleStyleSheet()['Normal']
style.wordWrap = 'LTR'
style.leading = 12
for legend in legends:
elements.append(Paragraph(str(legend),style))
如果图例太长,则末尾的文本根本不可见。 在这种情况下如何引入换行符。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这可能适用,也可能不适用,但我刚刚了解到,我通常用来在 Python 字符串中引入新行的
\n
会被 ReportLab 的 Paragraph 对象忽略。从邮件列表我了解到,在段落中您可以使用 HTML 的
来引入新行。这对我来说效果很好。
This may or may not apply but I just learned that
\n
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.
正如 PolyGeo 所说,您可以使用
将新行添加到段落。将新行转换为
标签更新代码
As PolyGeo says, you can use
<br />
to add new lines to a Paragraph.Convert new lines to
<br />
tagsUpdated code
抱歉,如果我将其误解为字母,但段落本身是“自动换行”的,与文档页面大小也有关。
亚洲语言的用户指南值为“CJK”,可能您的设置是根据其他内容(例如亚洲语言分词)执行文本搜索终点线。将其设置为 None 应该可以完成此操作。
Sorry if I misunderstood this as letter, but Paragraph itself is "word wrapped", in relation to document pagesize also.
There's userguide value of 'CJK' for Asian language, possibly your setting do the text to search for finishing line according to something else, like Asian language word splitting. Set it to None should do the thing.