如何使用 php 在 pdf 创建中包含换行符和空格?

发布于 2024-12-17 17:37:09 字数 395 浏览 1 评论 0原文

我正在尝试使用 php 创建 pdf 文档。

但是,我无法在 pdf 中获取新行。

nl2br 不起作用,所以我使用了

$newadd =  nl2br(str_replace('\r', ' ', $inputSafe['address']));

现在我在 html 中得到了正确的输出,

Naduvilachirayil House,
Anaprampal North P.O,
Thalavady

但在 pdf 中,我只得到

Naduvilachirayil House,<br>Anaprampal North P.O,<br>Thalavady.

I am trying to create a pdf document using php.

But, I can't get new line in the pdf.

nl2br is not working so I have used

$newadd =  nl2br(str_replace('\r', ' ', $inputSafe['address']));

Now I got the correct output in html as

Naduvilachirayil House,
Anaprampal North P.O,
Thalavady

But in pdf, I am getting only

Naduvilachirayil House,<br>Anaprampal North P.O,<br>Thalavady.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒儿 2024-12-24 17:37:09

看看这是否有帮助:

$newadd = nl2br(str_replace("\n\r", ' ', $inputSafe['address']));

see if this helps:

$newadd = nl2br(str_replace("\n\r", ' ', $inputSafe['address']));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文