tags:

views:

275

answers:

1

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..

A: 

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);
Wesley Mason