Simon Suh
Simon Suh

Reputation: 10882

How do I make a RTF (Rich Text Format) document through PHP from a form submission?

I'm searching on Google but most of the results I'm getting have these complicated software being used. I'm choosing to use RTF because it's the easiest to code straight through PHP and did it before but forgot the website I was getting help from.

could someone give me a brief summary of how to replace insertable variables in a pre-written rtf document with mysql form data using php? I have variable insertion locations marked in my rtf document with $variable1, $variable2 etc, which corresponds to the variable names in my mysql table.

Or could someone provide me with a link to an already existing tutorial on it please?

edit: and if it uses a prewritten software, it has to be free.

Upvotes: 0

Views: 4030

Answers (3)

Lawrence Cherone
Lawrence Cherone

Reputation: 46610

Basic rtf with replace: http://www.tuxradar.com/practicalphp/11/3/0 just really depends on how complex your pre-written rtf is

$rtf=<<<RTF
    {\rtf1
    \b [TITLE] \b0\par
    \b [MESSAGE] \b0\par
    }
RTF;

$rtf = str_replace('[TITLE]',$valueTitle,$rtf);
$rtf = str_replace('[MESSAGE]',$valueMessage,$rtf);

or you could build an rtf document as the data is retrieved, much like you would with html.

or use a class like: http://www.phpclasses.org/package/1805-PHP-Create-RTF-documents-from-HTML.html

Upvotes: 3

Simon Suh
Simon Suh

Reputation: 10882

I couldn't find the rtf tutorial I was looking for so just decided to use pdf, which is already well explained here in this stack overflow question.

How to make a pdf file using PHP

Upvotes: 0

Related Questions