Home > Software design >  Breakline in Paragraph Reportlab
Breakline in Paragraph Reportlab

Time:10-01

I am trying to add a breakline in Paragraph in Reportlab. While some HTML tags like works,
causes this exception:

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

This is where I wrap my text:

  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)

CodePudding user response:

Use <br/> instead of <br>.

Using <br> raises a ValueError: paraparser: syntax error: No content allowed in br tag


If using <br/> does not fix the issue then use a closing tag <br/> along with <br>.

Try:

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