How to put line break in mpdf when data is extract

2019-02-27 20:08发布

I am using MPDF to generate pdf files from data stored in mysql database. Though I could extract and display others data as expected, I could not display multiline text as they all comes in single line. Could someone help me to resolve this problem.

EG. My data from textarea is shown in database as: One

Two

Three

But in pdf it will ge generated as OneTwoThree

When I check in database using phpmyadmin its stored data as One\r\nTwo\r\nThree

Please help.

2条回答
做自己的国王
2楼-- · 2019-02-27 20:18

Try with this code. $finalString = nl2br($htmlOut);

查看更多
神经病院院长
3楼-- · 2019-02-27 20:36

MPDF is for generating PDF from HTML.

HTML shows your lines as OneTwoThree, because it does not care about line breaks. You should change the '\r\n' to HTML line breaks.

$finalString = str_replace("\r\n", "<br />", $htmlOut");
查看更多
登录 后发表回答