简体   繁体   English

RTF库-PHPrtf是否有人使用过?

[英]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.

相关问题 有人用过HipHop for PHP吗? - Has anyone used HipHop for PHP? 有没有人使用braintree进行基于令牌的交易? - has anyone used braintree for token based transactions? 有人用过 Yii 框架中的 tel: 协议吗? - Has anyone used the tel: protocol in the Yii Framework? 有没有人将HBase,Tornado,Cassandra或HipHop与Drupal一起使用? - Has anyone used HBase, Tornado, Cassandra or HipHop with Drupal? 是否有人将firephp与firefox 4和Zend Framework DB Profiler一起使用? - Has anyone used firephp with firefox 4 and Zend Framework DB Profiler? 这里有人用过木瓜吗? 是否有其他带有嵌入式浏览器堆栈的apache网络服务器可用 - Has anyone here used wapache ? Are there any alternative apache webserver with embedded browser stacks available 有没有人知道免费工具或如何将rtf转换为jpg - doe anyone know of a free tool or how to convert an rtf to a jpg 有人在Windows x64上为php 5.2.x编译了一个rabbitmq / amqp库 - Has anyone compiled a rabbitmq/amqp library for php 5.2.x on windows x64 有没有人使用过这个 Highrise API PHP Wrapper 库? 我需要帮助进行身份验证 - Has anyone worked with this Highrise API PHP Wrapper library? I need help authenticating CodeIgniter的好PayPal库,有人吗? - Good PayPal library for CodeIgniter, anyone?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM