Discussion:
saveasname not working - cfdocument
(too old to reply)
mark_la
2009-04-02 13:41:28 UTC
Permalink
Hi,

I am creating a pdf in a coldfusion page called template.cfm, the code is
below. I am not writing the PDF to a location on the server, but I am allowing
the user to save the pdf to their own computer. I would like to change the
filename of the PDF if the user chooses to save the PDF, the suggested filename
would be based upon the content, but in my example, I would like it to change
to 'newname.pdf'

I thought I would be able to use the saveasname attribute, but it doesn't seem
to be working. Every time the user hits the 'save' button, the filename always
displays as 'template.pdf'.

Can anybody tell me what I am doing wrong?

Thanks,
Mark



<cfsavecontent variable="variables.snapshotContent">

This is my PDF Content

</cfsavecontent>

<cfdocument format="PDF" name="docPDF" orientation="landscape"
saveasname="newname.pdf">
<cfoutput>#variables.snapshotContent#</cfoutput>
</cfdocument>

<cfset data = {author="I M D Author", Subject="This is very annoying",
Title="Taken From Raymond Camden"}>

<cfpdf action="setinfo" source="docPDF" info="#data#">

<cfcontent type="application/pdf" reset="true" variable="#toBinary(docPDF)#">
-==cfSearching==-
2009-04-02 17:38:57 UTC
Permalink
Post by mark_la
I thought I would be able to use the saveasname attribute,
Since you are not using cfdocument to write the pdf to the browser, try adding
a header:

<cfheader name="Content-Disposition" value="inline; filename=newname.pdf">
<cfcontent type="application/pdf" reset="true" variable="#toBinary(docPDF)#">
Loading...