I have done it using information Ms. Motlagh (thank you) posted in this
forum.
Here are the steps:
1. First, create the RTF template that you want in Word.
2. Save it as an RTF file.
3. Open it in NotePad or WordPad and you will see the code generated.
4. Find where your variables should be placed and replace the static text
with text like: [name]
5. Save this file.
6. Now, modify the following template for your purposes (make sure you point
to the correct location of the RTF template):
<CFSETTING ENABLECFOUTPUTONLY="YES">
<!-------------------------------------------------------
Generate a unique ID for the file in the temporary server
directory and get the file that is to be merged.
--------------------------------------------------------->
<CFSET OUTFILE=ROOT_PATH & "/rtf/" & SPEAKER_ID & ".doc">
<CFSET SOURCEFILE="#admin_Path#speaker_profile.rtf">
<!-------------------------------------------------------
If the file exists then delete the file from the server.
--------------------------------------------------------->
<CFIF FILEEXISTS(OUTFILE)>
<CFFILE ACTION="DELETE" FILE="#OutFile#">
</CFIF>
<!-------------------------------------------------------
Read the RTF file into memory so that it can be modified.
-------------------------------------------------------->
<CFFILE ACTION="read" FILE="#SourceFile#" VARIABLE="RTFDocument">
<!-------------------------------------------------------
Look for substition fields and substitute the proper data
into the document.
-------------------------------------------------------->
<CFSET RTFDOCUMENT=REPLACE(RTFDOCUMENT,"[name]","Reyhan Motlagh","ONE")>
<CFSET RTFDOCUMENT=REPLACE(RTFDOCUMENT,"[title]","Baby","ONE")>
<!-----------------------------------------------------------
Write the changed file to disk for outputting to the workstation.
------------------------------------------------------------>
<CFFILE ACTION="WRITE" FILE="#OutFile#" OUTPUT="#RTFDocument#"
ADDNEWLINE="No">
</body>
</html>
----- Original Message -----
From: Cary Gordon <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 23, 2000 5:06 PM
Subject: Re: ColdFusion Create RTF Files
> This is how we do it...
>
> <CFFILE ACTION="WRITE"
> FILE="fullyqualifiedfilepathto\somefile.rtf"
> OUTPUT="your rtf stuff with embedded variables">
>
> Make certain that you escape any pound signs in the rtf code.
>
> Cary
>
> At 03:00 PM 3/23/00 -0500, you wrote:
> >Does anyone have a working example of CF Code that will create an RTF
file ?
> >
> >It's my understanding that you need to start out with an RTF file with
the
> >appropriate CF tags in it. You call this RTF file with CF Content ?
> >
> >Sorry to ask such a broad question. Have never worked with RTF and I
need
> >to implement this now. I would usually figure this out myself but I
don't
> >have the time on this one.
> >
> >Thanks list !!
> >
> >Jonathan
>
>
> Cary Gordon
> The Cherry Hill Company
>
> --------------------------------------------------------------------------
----
> Archives: http://www.eGroups.com/list/cf-talk
> To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
>
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.