[英]RTF Library - PHPrtf Has anyone used it?
For some reason, my line breaks in my test.txt file are not being preserved. 由于某些原因,我的test.txt文件中的换行符未保留。
$sect->writeText(file_get_contents("test.txt"), $times12, $null);
Has anyone played around with this library? 有没有人玩过这个图书馆?
http://sourceforge.net/projects/phprtf/ http://sourceforge.net/projects/phprtf/
My question is: How can I preserve my line breaks from my test.txt file? 我的问题是:如何保留test.txt文件中的换行符? 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..
您可能需要具有该库的经验。
Looking at the source for PHPrtf it looks like the author has forgotten to include regular line breaks. 在查看PHPrtf的源代码时,似乎作者忘记了包含常规的换行符。 They've included DOS style line endings, "\\r\\n", which creates an RTF paragraph (\\par), but nothing which creates an RTF linebreak (\\line).
他们包括了DOS样式的行尾“ \\ r \\ n”,它创建了一个RTF段落(\\ par),但是没有一个东西创建了RTF换行符(\\ 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, eg: 您有2个选项,用\\ r \\ n替换get_file_contents()的输出中的(我认为是nix)行尾,以在RTF中创建段落,例如:
str_replace("\n", "\r\n", $text);
Or you can patch rtf/Container.php, specifically inserting the following at the top of "Container::writeText()": 或者,您可以修补rtf / Container.php,特别是在“ Container :: writeText()”的顶部插入以下内容:
$text = str_replace("\n", "\n".'\line ', $text);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.