[Python] setting width to textobject in reportlab

Discussão em 'Python' iniciado por Stack, Agosto 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am creating report using reportlab. Here is code to insert the text in report

    c = canvas.Canvas("reports/abc.pdf", pagesize=A4)
    t = c.beginText()
    t.setFont('Times-Roman', 14)
    t.setTextOrigin(0.3*inch,6.5*inch)
    wraped_text = "\n".join(wrap(Desc,100)) # 100 is line width
    t.textLines(wraped_text)
    c.drawText(t)


    This code works with normal string but when some capital letters comes in text its width would increase and it goes out of the page. So, can I set the width of text with respect to width of page rather than depending on the number characters ?

    Continue reading...

Compartilhe esta Página