Skip to main content
Inspiring
October 30, 2009
Answered

saveasname not working with adobe toolbar buttons

  • October 30, 2009
  • 1 reply
  • 1173 views

I am on CF8, using cfdocument to display a cfm page as a pdf.  I have saveasname set in the cfdocument tag but that only works when you do a file->save as while viewing the pdf.  If you use adobe's toolbar buttons to "save this file to your computer" or to "attach this pdf file to an email message" the saveasname isn't working, it defaults to index.cfm.  How do I get the adobe buttons to use saveasname?

- Tom

    This topic has been closed for replies.
    Correct answer -__cfSearching__-

    I tried adding the cfheader but it

    didn't work, probably because I'm using cfdocument

    format="pdf" for the page content.

    Are you using it correctly? Save the cfdocument content to variable , then use cfheader + cfcontent to display it.

    (Example stolen from Raymond Camden's blog)

    http://www.coldfusionjedi.com/index.cfm/2008/4/4/ColdFusion-801--Easier-to-add-PDF-Watermarks

    ... ]]>

    <cfcontent type="application/pdf" variable="#toBinary(mypdf)#"

    1 reply

    ilssac
    Inspiring
    October 30, 2009

    You don't!  You are not allowed to control what the client save his or her files as.  If you did with any file that I downloaded from you; I would call hacker on you and never visit your site again.

    You can, however, provide a 'suggested' file name for the download in the HTTP headers.  ColdFusion provides the <cfheader...> tag to add HTTP headers to the response.

    The nomal header to sugest the file name is the Content-Dispostion header.

    <cfheader NAME="Content-Disposition" VALUE="attachment; filename=mySexyFile.pdf">
    
    Inspiring
    October 30, 2009

    Well, its an admin page that will only be used by a couple of people.  They don't mind that I'm changing the file name and would prefer it.  I tried adding the cfheader but it didn't work, probably because I'm using cfdocument format="pdf" for the page content.

    ilssac
    Inspiring
    October 30, 2009

    That's the thing with standards.  Your admin people do not mind this, but if you can do it for them, then unethical developers can do it for nefarious reasons.