RTF库-PHPrtf 有人用过吗?

发布于 2024-07-26 19:46:38 字数 392 浏览 1 评论 0原文

由于某种原因,我的 test.txt 文件中的换行符没有被保留。

$sect->writeText(file_get_contents("test.txt"), $times12, $null);

有人玩过这个库吗?

http://sourceforge.net/projects/phprtf/

我的问题是:如何保留我的我的 test.txt 文件中的换行符? 发生的情况是文档只是将所有文本合并在一起,没有换行符。

有任何想法吗? 您可能必须有使用这个库的经验..

For some reason, my line breaks in my test.txt file are not being preserved.

$sect->writeText(file_get_contents("test.txt"), $times12, $null);

Has anyone played around with this library?

http://sourceforge.net/projects/phprtf/

My question is: How can I preserve my line breaks from my test.txt file? What is happening is the document is just merging all the text together without the line breaks.

Any ideas? You would probably have to have experience with this library..

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

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

发布评论

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

评论(1

撩动你心 2024-08-02 19:46:38

查看 PHPrtf 的源代码,看起来作者忘记了包含常规换行符。 它们包含 DOS 风格的行结尾“\r\n”,它创建 RTF 段落 (\par),但没有创建 RTF 换行符 (\line)。

您有 2 个选项,用 \r\n 替换 get_file_contents() 输出中的(我猜是 nix)行结尾,以在 RTF 中创建段落,例如:

str_replace("\n", "\r\n", $text);

或者您可以修补 rtf/Container.php,具体插入以下内容在“Container::writeText()”的顶部:

$text = str_replace("\n", "\n".'\line ', $text);

Looking at the source for PHPrtf it looks like the author has forgotten to include regular line breaks. They've included DOS style line endings, "\r\n", which creates an RTF paragraph (\par), but nothing which creates an RTF linebreak (\line).

You have 2 options, replace your (I presume nix) line endings in the output from get_file_contents() with \r\n's, to create paragraphs in the RTF, e.g.:

str_replace("\n", "\r\n", $text);

Or you can patch rtf/Container.php, specifically inserting the following at the top of "Container::writeText()":

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