R
R
Ruslan Mordovanech2022-01-10 12:42:33
Python
Ruslan Mordovanech, 2022-01-10 12:42:33

How to transfer backex without \n to pdf?

text = "Hello\nThis is a multiline text\nHere we have to handle line height manually\nAnd check that every line uses not more than pagewidth"
c = canvas.Canvas("test.pdf")

for i, line in enumerate(text.splitlines()):
    c.drawString(1 * cm, 29.7 * cm - 1 * cm - i * cm, line)

c.save()

How can you wrap the text without n if by the index of letters [:22].

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2022-01-10
@Hery1

for i in range(0, len(text), 22):
    line = text[i:i+22]

Well, further in the text.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question