I am trying to read from excel file and generate the output file using reportlab library in python. Now the text in excel file is as below :-
When I am reading it into pdf I am not able to resume newlines.
Below is the code I am using for the same :-
for body_column in body_columns:
body_para = Paragraph(f'{body_column}', style['BodyText'])
details.append(body_para)
doc.multiBuild(details)
Could anyone please help me with this?
When you're using the paragraph with reportlab, it treats your text like HTML. This means that it doesn't interpret \n as a new line. Instead, you could replace the '\n' with '< br/ >' (without the spaces), as such:
for body_column in body_columns:
body_column = body_column.replace('\n', '<br/>')
body_para = Paragraph(f'{body_column}', style['BodyText'])
details.append(body_para)