Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Form to create MS Word attachments

Status
Not open for further replies.

j0nxuser

Technical User
May 4, 2003
31
0
0
US
I'm Running Centos5 have a solid php form that submits the raw data to an oracle database and then emails the user a copy of what they submitted. My next challenge is the take the input off of the form, jam it into a word doc and then attach as a LOB to oracle and then attach to the email that I'm already sending.

Using the generic example below, I can create that necessary *.doc file

<?
$fp = fopen("amit.doc", 'w+');
$str = "<B>This is the text for the word file created through php programming</B>";

fwrite($fp, $str);

fclose($fp);
?>

However when you open this up in MS Word it prompts you to pick the encoding type and when you open up the file, it's pretty much raw text (the bold tags in the above example are ignored). What do I have to do to have the *.doc understand html that I throw in there, simple sample like this:

<?
$comment = "<p align=center><b>HEADER LINE</b></p>";
$comment.= "blah, blah, blah";
$fp = fopen("amit.doc", 'w+');
fwrite($fp, $comment);

fclose($fp);
?>

Thank you,
Mark
 
you would have to write the data in a format that MS Word understands. I believe that the document format is publicly available but be warned that it is not trivial to insert even a small piece of text.

other methods are to use PHP to open a word document and insert contents into it by using COM objects. you need to be on a windows platform to make this work.

better, I feel, is to re-evaluate the need for the database attachments to be native MS Word documents.why not try for rich text format as an intermediate step? this class purports to translate html to rtf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top