You can use the cfdocument filename
attribute to save the generated PDF or SWF output to a file, as the following example shows:
<!--- The compasstravel database is part of the Getting Started
tutorial application, found under the cfdocs directory. --->
<cfquery datasource="compasstravel" name="compasstrips">
SELECT tripName, tripDescription, tripLocation, price
FROM trips
ORDER BY price
</cfquery>
<cfdocument format="pdf" filename="#GetDirectoryFromPath(GetTemplatePath())#/compasstrips.pdf" overwrite="yes">
<cfdocumentsection>
<h1 align="center">Compass Travel</h1>
<h2 align="center">Destination Guide</h2>
<p align="center"><img src="cfdocs/getting_started/photos/somewhere.jpg"></p>
</cfdocumentsection>
<cfdocumentsection>
<cfdocumentitem type="header">
<font size="-3"> <i>Compass Travel Trip Descriptions</i></font>
</cfdocumentitem>
<cfdocumentitem type="footer">
<font size="-3"> <cfoutput>Page #cfdocument.currentpagenumber#</cfoutput> </font>
</cfdocumentitem>
<cfoutput query="compasstrips">
<hr>
<h2>#tripName#</h2>
<p><b>#tripLocation#</b></p>
<p>Price: #DollarFormat(price)#</p>
<p>#tripDescription#</p>
</cfoutput>
</cfdocumentsection>
</cfdocument>