How to put line break in mpdf when data is extracted from mysql database

孤者浪人 提交于 2019-12-31 04:56:06

问题


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.


回答1:


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




回答2:


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");


来源:https://stackoverflow.com/questions/24322530/how-to-put-line-break-in-mpdf-when-data-is-extracted-from-mysql-database

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!