Skip to main content
Inspiring
April 2, 2009
Question

saveasname not working - cfdocument

  • April 2, 2009
  • 1 reply
  • 1060 views
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

    This topic has been closed for replies.

    1 reply

    Inspiring
    April 2, 2009
    > 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="attachment; filename=newname.pdf">
    <cfcontent type="application/pdf" reset="true" variable="#toBinary(docPDF)#">