I installed
RTF::Writer just to test your code, and after some edits I could make it compile. (For some reason,
add_bgcolor isn't a recognized method, so I commented those out; and the use of your private module at the top too.)
I initially got a blank file too. Then I noticed you have mixed two alternatives, you have to use either
$fh = RTF::Writer->new_to_file($rtfReport);
or
$fh = RTF::Writer->new_to_string(\$RTF_obj);
but not both. Don't mix them.
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
$fh->print(\$RTF_obj);
near the end, it makes the document exactly twice as long and worse, it corrupts it as Word can no longer read it.
So: near the top, just use
$fh = RTF::Writer->new_to_string(\$RTF_obj);
you'd even better delete every mention of
$rtfReport; and near the bottom, right under
$fh->close();, add
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.