【发布时间】:2021-10-21 11:29:58
【问题描述】:
我正在尝试使用 reportlab 将一些数据放入 PDF 中。我从数据框中获取这些数据。但是,由于一个字段是一个小文本,因此应该有一些断线以使其在 PDF 中可读。
我提取数据的代码部分:
style_texto4=ParagraphStyle(name='Normal4', fontName='Times-Roman', fontSize=15)
texto4=Paragraph(f"{df.set_index('concat').loc[i]['Text']}", style=style_texto4)
style_texto4.leading=16
texto4.wrapOn(c, 600, 600)
texto4.drawOn(c, 90, 380)
想象一下我的文字是这样的:
'Hello, my name is John and I am trying to insert some breaklines \n in my pdf so that it displays correctly in my html format'.
这引发了:
syntax error: No content allowed in br tag
【问题讨论】:
-
欢迎来到 Stack Overflow。请不要大喊大叫。标题会自动突出显示样式。