Trouble displaying RTF file with PHP echo - Help!

A

Anonymous

Guest
Hi PHP'ers,
I am building a web page that takes user input and generates an RTF file, which the user can then preview/print from the browser. Not as easy as it sounds; at least not for me.

I used the PHP 'echo' command to display the RTF file in the browser, but it's not working cleanly. I want it to show the 'interpreted' file output, but it only shows the raw uninterpreted RTF file from the echo command, and it only does that after prompting me with a dialogue box to open or save it.

I have inserted 'header(content-type: application/rtf)' in the hopes that it will open the right application on the server side. When testing in local mode (using Apache minixampp) it actually opens Word but does not close the raw RTF browser window. In live mode on a host provider, it opens Dreamweaver.

Is there any simple way to display an RTF file in the browser, in formatted output and without those annoying dialogue boxes?
 
shawbapmp said:
Hi PHP'ers,
I am building a web page that takes user input and generates an RTF file, which the user can then preview/print from the browser. Not as easy as it sounds; at least not for me.

I used the PHP 'echo' command to display the RTF file in the browser, but it's not working cleanly. I want it to show the 'interpreted' file output, but it only shows the raw uninterpreted RTF file from the echo command, and it only does that after prompting me with a dialogue box to open or save it.

I have inserted 'header(content-type: application/rtf)' in the hopes that it will open the right application on the server side. When testing in local mode (using Apache minixampp) it actually opens Word but does not close the raw RTF browser window. In live mode on a host provider, it opens Dreamweaver.

Is there any simple way to display an RTF file in the browser, in formatted output and without those annoying dialogue boxes?
I'm sure what if you are use echo while output RTF file format, you are get somthing this:
{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl
{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman{\*\falt Courier New};}
{\f1\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial{\*\falt Courier New};}{\f14\fnil\fcharset136\fprq2
try use COM support functions for Windows
 
Thanks. I will look into that.

I seem to recall that I visited that topic before and there was something prohibitive about using it, but I will investigate again.
 
Hello again, Wizard,

As a follow-up to my last reply, I cannot use COM objects because that requires a Windows operating system on the host server. My host provider runs Unix (or Linux). So I'm back to square one.

Any other ideas?
 
shawbapmp said:
Hello again, Wizard,

As a follow-up to my last reply, I cannot use COM objects because that requires a Windows operating system on the host server. My host provider runs Unix (or Linux). So I'm back to square one.

Any other ideas?
Firstly try store document somethere (root, where you are storing index.php like), secondary try open trought browser it.
If you are have a good result with opening (document opened in MS Word), that's good.
 
Hi Wizard,

Well, I tried copying a test RTF file onto the host provider server and yes, it opens in MS Word, but not before showing me that dreaded "File Download" dialogue box, which asks me to open or save the file. It is probably using my own PC (client) copy of MS Word to open it.

I do not want that dialogue box to show to the user because I don't want to give the user the option of downloading it. I only want the user to see it and print it right from the browser.

Is there any way of having the host server open it in the background with its own word processor application (which is probably OpenOffice Writer)?

Or am I asking too much?
 
shawbapmp said:
I do not want that dialogue box to show to the user because I don't want to give the user the option of downloading it. I only want the user to see it and print it right from the browser.

If you are do not want dialog opening to you need some RTF parser. try see at http://codewalkers.com

shawbapmp said:
Is there any way of having the host server open it in the background with its own word processor application (which is probably OpenOffice Writer)?
Sorry, it's impossible.
 
OK, now I'm really scared off the whole idea.

I'll have to rethink my approach.

Thanks for your help.
 
I'm propose to you forget about RTF.
Try better open new html page without any menus, scrolls, and etc.
 
Good advice Wiz.

Sometimes the most simple approach is the best approach.

Goodbye RTF, hello HTML page.
 
Back
Top