/ Published in: ColdFusion
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<cfsetting showdebugoutput="yes"> <Cfset personnel.jobtitle = "Webmaster"> <cfset personnel.location = "The dungeon"> <cfset personnel.skills = "Can program and stuff"> <cfset personnel.name = "Bob Jones"> <cfset thisPath = ExpandPath("*.*")> <cfset thisDirectory = GetDirectoryFromPath(thisPath)> <!--- Get the RTF data from the base file ---> <Cffile action="read" file="#thisDirectory#\pagepart.txt" variable="PagePart"> <!--- Replace the placeholders with data ---> <Cfset pagePart = replacenocase(pagepart, '~~~recordFor~~~', 'Bob Jones') > <Cfset pagePart = replacenocase(pagepart, '~~~jobtitle~~~', 'Devision Head') > <Cfset pagePart = replacenocase(pagepart, '~~~workLocation~~~', 'Office') > <Cfset pagePart = replacenocase(pagepart, '~~~skills~~~', 'Management') > <!--- Get the image and convert to Hex ---> <cffile action="readbinary" file="#thisDirectory#\please_buy_cookies.jpg" variable="getImage"> <Cfset getImage = binaryencode(getImage, 'hex') > <!--- Replace image placeholder with image data ---> <Cfset pagePart = replacenocase(pagepart, '~~~image~~~', getImage) > <!--- Push to the users computer as if they asked to download a file. ---> <cfheader name="Content-Disposition" value="attachment; filename=test.rtf"> <CFCONTENT TYPE="application/rtf" ><CFOUTPUT>#pagePart#</CFOUTPUT>