I don't think so, when your page gets compiled I always get errors
trying to use <cfif> with <cfdocument>. When I have had to do this I
just encapsulate my document writing into a .cfc, and call 2 different
methods.  Ie writePdfToBrowser, or writePdfToFile.  Then just
<cfinclude> your actual document output inside the different structured
<cfdocument> tags and you should be all set ;)

Chris 

-----Original Message-----
From: Pete Ruckelshaus [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 02, 2006 2:11 PM
To: CF-Talk
Subject: How do I hate thee, cfdocument? Let me count the ways...or,
using 1 piece of code to either stream or write.

I have such a love/hate relationship with cfdocument, it's pathetic.

I'm writing an app.  In my app I generate a PDF using the cfdocument
tag.  Most of the time, I just want the PDF streamed to the browser, so
I don't include the filename attribute and all is well.  However, using
the same code to generate the same document, some of the time I want to
actually create a file to send as an email attachment. 
"Fine." says I.  "I'll just either pass in a filename attribgute or not"

Alas, no.  Using the following code:

<cfparam name="file_only" default="false"> <cfscript>
        if (file_only EQ "true") {
                tmp.filename = GetDirectoryFromPath(GetTemplatePath()) &
"test.pdf";
        } else {
                tmp.filename = "";
        }
</cfscript>
<cfdocument format="PDF" pagetype="letter" margintop="1"
marginbottom="1" marginright="0" marginleft="0" orientation="portrait"
unit="cm" fontembed="Yes" backgroundvisible="No"
filename="#tmp.filename#" overwrite="yes">

I am given a "fileNotFoundException" error message.  OK, perhaps it
doesn't like my passing in a dynamic filename.  Why don't I try two
different opening cfdocument tags in an if statement?  Nope, that
doesn't work either.

Is there any way to use a single cfdocument tag to either stream a PDF
to the browser OR save the PDF as a file?

Thanks

Pete



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239305
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to