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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create DOC and RTF documents

Status
Not open for further replies.

ltoni

Technical User
Aug 9, 2000
7
IT
Hi,
I have a problem: I'm able to create PDF files with pdflib 3.20 on my php 4.0, but I can't create doc or rtf documents.
Anyone can help me?

thanx to all,
Luca
 
Here is the basic code for it.

I am not sure if there is a library to do special types of formatting.

[tt]
<?php
$fh = fopen(&quot;file.doc&quot;, &quot;wb&quot;);
fwrite($fh,&quot;i am in a doc file&quot;);
fclose($fh);
?>
[/tt]

Hope this helps,

-Vic vic cherubini
vikter@epicsoftware.com
====
Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director
====
 
The above example just creates a text file with a .doc extension. Yes, it can be opened by Word, but it is still just a text file. If you want to have any formatting, etc... you will have to actually create in the Word file format.

PHP supports a certain amount of COM, allowing you to create documents in Microsoft format ( but you need to be running a Windows server. It has nothing to do with PDFlib.

RTF files, though are another thing. I don't think PDFlib supports creating RTF files, but RTF itself is an open format, actually a markup language of its own saved as text. Create an RTF doc in Word, and then examine it in a text editor and you will see. has some info on the specs.

So... knowing this, you should be able to just get PHP to spit out the appropriate text markup for an RTF document. I'm sure it will be a bit of work, but it wouldn't surprise me if someone out there has already done this and created a library for it. (If not in PHP, for sure in Perl) If someone hasn't done this, then you could contribute nicely to the PHP community by building some classes for RTF file creation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top