Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

saveasname not working with adobe toolbar buttons

Explorer ,
Oct 30, 2009 Oct 30, 2009

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

1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Oct 30, 2009 Oct 30, 2009

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

<cfdocument format="pdf" name="mypdf">...</cfdocument> <cfheader name="content-disposition" value="attachment; filename=""test.pdf""

...
Translate
Valorous Hero ,
Oct 30, 2009 Oct 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">
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 30, 2009 Oct 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 30, 2009 Oct 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 30, 2009 Oct 30, 2009

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

<cfdocument format="pdf" name="mypdf">...</cfdocument> <cfheader name="content-disposition" value="attachment; filename=""test.pdf"""></cfheader>

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 30, 2009 Oct 30, 2009
LATEST

I wasn't using it correctly.  Works now!

Thanks for the help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources