How to add line break in pdf generated using pdfkit.from_string()?

Viewed 1337

I try to generate a pdf file from a string using pdfkit. However, in the result all new line characters \n are ignored. Thus, I get a pdf with a string printed as a single sentence. For example:

import pdfkit
s = "Some text\n"
s += "Ok, let's add something more\n"
s += "And more..."
pdfkit.from_string(s,"file.pdf",{'encoding':'utf-8'})

Following code results in a following output (meaning a pdf file with following text):

Some text Ok, let's add something more And more...

However, this is what I want to achieve:

Some text

Ok, let's add something more

And more...

0 Answers
Related