The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Creatng Word docs from PHP

Hey

I'm working on an application currently where I have 8 word templates. I want to be able to create a new document based on the template and fill in the missing information from a user input and database.

I'm not having much luck finding anyting to fill my need. I was thinking that maybe I need to create Word Documents as objects and pass parameters to fill in the missing pieces on my templates?

Any help is highly appreciated!

Cheers
Talib Kweli
Saturday, July 08, 2006
 
 
Are you running PHP on Windows?  If so, you can use COM.

If you're not on Windows, your best bet is probably to write out RTF instead of a word document.
Almost H. Anonymous Send private email
Saturday, July 08, 2006
 
 
Yes PHP is running on Windows. I found some information on using COM but some sites are saying that it can hog resorces and be a hassle?

I'm going to have a play tomorrow with COM, I think I will go this way.

Thanks for your reply
Talib Kweli
Saturday, July 08, 2006
 
 
"some sites are saying that it can hog resorces and be a hassle?"

Yup.  That sounds about right.  Using word from a PHP application (or basically any server application) is a pain.  You might, however, get lucky.  If you don't need serious performance and aren't doing anything to complex than it just might work fine.
Almost H. Anonymous Send private email
Saturday, July 08, 2006
 
 
Gave this a try today, seems to work quite well for me here with COM. Been playing around with the Word Object Model and quite happy with it all!

I have another question though :)

If I use templates for my documents is it possible to send data to the document that goes to a specific location in the document?

Many Thanks
Talib Kweli
Sunday, July 09, 2006
 
 
The other solution is to resave you templates in RTF with special markers indicating where your data goes such as ****FiratName****, ****Surname****.

You can then open the RTF file as raw text, do a quick find/replace and send the RTF file. Most people will have this open automatically in Word and won't notice a difference.

This solution would also then work on a non-Microsoft server and work for clients without Word (or a Word document compatible editor) installed.
Adrian
Monday, July 10, 2006
 
 
Thanks for your post adrain. Yeah this looks like another pluasiable solution.

I've got most of what I want working now and found the documentation for Word 2003's Object Model.
Talib Kweli
Monday, July 10, 2006
 
 
Be very, very careful when using Word automation from a server application.

I did a small troubleshooting job at a company that was using Word to generate reports on a server. One day their reporting system just stopped.

It turned out that Word had put up a dialog box. Of course, on a server there's nobody there to click "OK" so everything, stopped.
Chris Tavares Send private email
Monday, July 10, 2006
 
 
Thanks Chris, a number of sites have mentioned this.

I only have 8 single documents to work with. So the scope of the project is quite small.

But I will be sure to test extensivily before I deploy :-)
Talib Kweli
Monday, July 10, 2006
 
 
If your users can be guaranteed/required to have Word 2003, you might consider generating WordML instead.
Chris Altmann
Monday, July 10, 2006
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz