【问题标题】:Breakline in Paragraph Reportlab段落 Reportlab 中的断线
【发布时间】:2021-09-30 09:42:20
【问题描述】:

我正在尝试在 Reportlab 的段落中添加断线。虽然某些 HTML 标记可以正常工作,但
会导致此异常:

caused exception paraparser: syntax error: No content allowed in br tag

这是我包装我的文字的地方:

  style = ParagraphStyle(
      name='Normal',
      spaceAfter=40,
      fontName='Times-BoldItalic',
      fontSize=18,
  )

text=Paragraph(f"<p> <b>{df.set_index('concat').loc[i]['Title']}</b> <br> Some more text </p>", style=style)

【问题讨论】:

    标签: python html reportlab


    【解决方案1】:

    使用&lt;br/&gt; 而不是&lt;br&gt;

    使用&lt;br&gt; 会引发ValueError: paraparser: syntax error: No content allowed in br tag


    如果使用 &lt;br/&gt; 不能解决问题,请使用结束标记 &lt;br/&gt;&lt;br&gt;

    试试:

    text=Paragraph(f"<p> <b>{df.set_index('concat').loc[i]['Title']}</b> <br> <br/>Some more text </p>", style=style)
    

    【讨论】:

    • 谢谢,成功了。
    猜你喜欢
    • 2016-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    • 1970-01-01
    • 2018-06-14
    • 1970-01-01
    • 2019-08-27
    相关资源
    最近更新 更多