Thanks Barney, that's a great idea. I'll try that and cffile.
On 5/2/06, Barney Boisvert <[EMAIL PROTECTED]> wrote:
> Always write it to a file (using a temp file if you want to stream
> it), and then optionally use a CFCONTENT to stream it? Hardly elegant
> or performant, but it will get the job done.
>
> cheers,
> barneyb
>
> On 5/2/06, Pete Ruckelshaus <[EMAIL PROTECTED]> wrote:
> > 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
>
> --
> Barney Boisvert
> [EMAIL PROTECTED]
> 360.319.6145
> http://www.barneyb.com/
>
> Got Gmail? I have 100 invites.
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239308
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