read ms-word rtf/doc into variable - change data - then outp

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alltimefav
Forum Newbie
Posts: 3
Joined: Thu Apr 26, 2007 6:36 pm

read ms-word rtf/doc into variable - change data - then outp

Post by alltimefav »

I can get my PHP 5 code to read text into a file but NOT msword or .rtf

opening the document works fine also

here's the code

$ht = file( '/pathtotemplate/contract1.htm' );
$ht = implode( '', $ht ); // don't know what this is for

// substitute stuff here in the original rtf or doc file (works on html data but not rtf or doc)
$ht = str_replace("[[longdate]]",$ld,$ht);

header("Content-Type: application/msword");
header("Content-Disposition: filename=\"myfile.rtf\"" );
header("Pragma: no-cache");
header("Expires: 0");

print $ht;

exit;
alltimefav
Forum Newbie
Posts: 3
Joined: Thu Apr 26, 2007 6:36 pm

Post by alltimefav »

using an HTML template works fine

$ht = file( '/pathtotemplate/contract1.htm' );

output works to screen in html

using this does not (rtf file stored as text on my server)

$ht = file( '/pathtotemplate/contract1.rtf' );

output = blank
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

open a word file in notepad and take a look at it - that's what you're dealing with in PHP.
alltimefav
Forum Newbie
Posts: 3
Joined: Thu Apr 26, 2007 6:36 pm

Post by alltimefav »

With RTF though it is just a "text" file.
Post Reply