Conditionally Apply cfdocument tag
I would like to display a .cfm as HTML or as a pdf, controlled by a POST variable. I had considered having a cfm for the html (let's call it view.cfm), then have a view_pdf.cfm that merely had a <cfdocument format="pdf" src="view.cfm"> tag. However, this did not work--I assume that that is because the src attribute only accepts html documents. I then tried something like the following:
<cfif checkforvariablehere >
<cfdocument format="pdf" > </cfif> OUTPUT STUFF HERE <cfif checkforvariablehere >
</cfdocument> </cfif>
However, this gave me problems with the closing cfdocument tag, which is sensible since the tags overlap. The only way I have found is to have a cfif/cfelse structure, with the output in cfdocument tags in the first and without cfdocument tags in the second. This is, of course, stupid, since now any change I make to output I have to make in two places. Is this the only solution available to me, or is there something else I can use?
