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

printing dynamic RTF documents

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
0
0
US
have a page that is supposed to loop through a set of results and create an rtf document for each returned record. But it is currently only creating one rtf document, and it's for the first record. Does anyone know how to change my code so it creates a document for each result. Preferrably, all documents would be created with in the same rtf...that is each document is a page long, and for each result, a new page would be created within the same rtf document. But seperate documents would work too.

Here's the code:
<cfset contact_list = form.contact_id>

<cffile action=&quot;read&quot; file=&quot;\\devweb01\inetpub\zone.specialtyrisk.com\application\contact\questionnaire\q_print.rtf&quot; variable=&quot;RTF&quot;>

<cfloop list=&quot;#contact_list#&quot; index=&quot;i&quot;>

<cfquery name=&quot;contact_info&quot; datasource=&quot;#application.datasource#&quot;>
SELECT dob, cert_number, ssn, f_name, l_name
FROM sri_contact.dbo.contact_cob_questionnaire
WHERE contact_id = #i#
</cfquery>

<cfset rtf = replace(RTF,&quot;%dob%&quot;,contact_info.dob)>
<cfset rtf = replace(RTF,&quot;%cert_num%&quot;,contact_info.cert_number)>
<cfset rtf = replace(RTF,&quot;%ssn%%&quot;,contact_info.ssn)>
<cfset rtf = replace(RTF,&quot;%f_name%&quot;,contact_info.f_name)>
<cfset rtf = replace(RTF,&quot;%l_name%&quot;,contact_info.l_name)>

<cfheader name=&quot;Content-Type&quot; VALUE=&quot;application/rtf&quot;>
<cfheader name=&quot;Content-Disposition&quot; value=&quot;attachment; filename=q_print.rtf&quot;>
<cfcontent type=&quot;application/rtf&quot;><cfoutput>#RTF#</cfoutput>

</cfloop>
 
Just a quick look at your code, but it looks like you read the base file into a variable RTF outside of your loop so it comes in once. Then the first time you loop you replace the data placeholders with the real data. Any loop after that would not find any placeholder to replace.



 
Hmmm,

Now it creates an rtf for whichever record is last in the returned results, whereas before it created it for the first returned result. But it still is only creating the rtf for one record.

Any thoughts?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top