• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

PHP and RTF

alocurto

Platinum Member
I currently have a large string constructed that represents an RTF file. I can echo the string to the screen, copy it and save the text as an rtf. When I open it the RTF displays fine.

What I want to do is have that string automatically get sent to the user when the access the page with the string.

I can always write a file on the server and have it get downloaded then create a cron job to clean up old RTFs every so often BUT I wanted to know if anyone has a better idea. Let me know if you can think of one.
 
Err...I hope I understand your question correctly...
Try this code:

<?

$rtfString = '{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
{\f46\fswiss\fcharset0\fprq2{\*\panose 020b0603020202020204}Trebuchet MS;}{\f59\froman\fcharset238\fprq2 Times New Roman CE;}{\f60\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f62\froman\fcharset161\fprq2 Times New Roman Greek;}
{\f63\froman\fcharset162\fprq2 Times New Roman Tur;}{\f64\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f65\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f66\froman\fcharset186\fprq2 Times New Roman Baltic;}
{\f67\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f519\fswiss\fcharset238\fprq2 Trebuchet MS CE;}{\f520\fswiss\fcharset204\fprq2 Trebuchet MS Cyr;}{\f522\fswiss\fcharset161\fprq2 Trebuchet MS Greek;}
{\f523\fswiss\fcharset162\fprq2 Trebuchet MS Tur;}{\f526\fswiss\fcharset186\fprq2 Trebuchet MS Baltic;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;
\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 Normal;}{\*\cs10 \additive \ssemihidden Default Paragraph Font;}{\*
\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}}{\*\rsidtbl \rsid15861053}{\*\generator Microsoft Word 10.0.2627;}{\info{\title Hello}
{\author Dark Tubbly}{\operator Dark Tubbly}{\creatim\yr2003\mo7\dy27\hr16\min47}{\revtim\yr2003\mo7\dy27\hr16\min47}{\version1}{\edmins0}{\nofpages1}{\nofwords0}{\nofchars5}{\*\company None}{\nofcharsws5}{\vern16437}}
\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1800\dgvorigin1440\dghshow1\dgvshow1
\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct\asianbrkrule\rsidroot15861053 \fet0\sectd
\linex0\endnhere\sectlinegrid360\sectdefaultcl\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4
\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}
{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
\fs24\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 {\f46\fs20\insrsid15861053 Hello}{\f46\fs20\insrsid15861053\charrsid15861053
\par }}';

header("Content-type: application/rtf");
print $rtfString;
?>
 
Let me try that darktubbly.

Basically when u hit the page with a browser you see a bunch of text (the actual underlying text of an RTF). What I want to happen is for the browser to interpret that into an rtf downloadable file or launch it in an associated app. I think setting the mime type will do it. Don't know why I didn't think of that.
 
setting the header type worked. But now the file downloaded is a php file. Is there a way to make the extension a rtf? Can I set the file name to be downloaded without changing the name of the server side file?
 
Back
Top