in reply to Re^4: Displaying RTF string to browser
in thread Displaying RTF string to browser
I initially got a blank file too. Then I noticed you have mixed two alternatives, you have to use either
or$fh = RTF::Writer->new_to_file($rtfReport);
but not both. Don't mix them.$fh = RTF::Writer->new_to_string(\$RTF_obj);
For this application, it makes most sense to use the $RTF_obj, because it holds the entire RTF document in memory.
And delete the line
near the end, it makes the document exactly twice as long and worse, it corrupts it as Word can no longer read it.$fh->print(\$RTF_obj);
So: near the top, just use
you'd even better delete every mention of $rtfReport; and near the bottom, right under $fh->close();, add$fh = RTF::Writer->new_to_string(\$RTF_obj);
print $RTF_obj;
That's it. Drop the code I gave you earlier to read out the contents of the file, as there is no longer a file, you don't need it. Instead, you're printing out the contents of a string.
HTH.
|
|---|