我正在嘗試使用 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
uj5u.com熱心網友回復:
換行符 (\n) 不起作用。您可以通過使用<br />標簽來實作這一點。
幫助:如何在 ReportLab 段落中插入回車?
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/329258.html
上一篇:對齊到頁面的中心
