ReportLab - How to add a space between words

I have a text:

elements.append(Paragraph(<font size=10>word1 word2</font>, styleSheet["Normal"]))

      

I want to add a space between word1 and word2:

word1    word2

      

How can i do this?

+3


source to share


2 answers


I know I'm a little late for this, but adding the html for the non-breaking space &nbsp;

worked for me.



+4


source


I doubt there is an easy solution for this.

As a workaround, you can try adding a blank (color or background color) 1px x 1px image in your paragraph and rescaling it to the desired width.

<font size=10>word1<img src="../path/to/image" width="10" />word2</font>

      



Another (tedious) solution would be to host your paragraph yourself with text objects created by canvas.beginText (x, y).

textobject = canvas.beginText(x, y)
textobject.setWordSpace(10)
textobject.textLine("word1 word2")
... (setting other parameters such as font etc.)
canvas.drawText(textobject)

      

Hope it helps.

+2


source







All Articles