I am trying to dynamically create an embedded PDF file which, when the user wants to save it, asks for my user-defined file name. According to the documentation , the attribute saveasnameshould do what I want.
(format only = "PDF") The file name that appears in the SaveAs dialog box when the user saves the PDF file written to the browser.
However, what happens in IE 9 and Firefox 13.0.1 is that the file name that appears in the SaveAs dialog box matches my CF template, but with the PDF extension. (In other words, my code is in makepdf.cfm, and SaveAs prompts me to save makepdf.pdf.) However, it works fine in Chrome. (All in Windows 7.)
Here is my code for creating a PDF:
<cfdocument format="pdf" bookmark="true" saveasname="MyReport.pdf">
If I explicitly declare the content and content type, e.g.
<cfheader name="Content-Disposition" value="inline; filename=MyReport.pdf">
<cfcontent type="application/x-pdf">
<cfdocument format="pdf" bookmark="true" saveasname="MyReport.pdf">
- Chrome tells me that "Content-Disposition" has been announced twice
- Firefox tells me that the PDF file is corrupted.
- IE just ignores it (and still doesn't show the correct file name)
If I just rely on the title
<cfheader name="Content-Disposition" value="inline; filename=MyReport.pdf">
<cfcontent type="application/x-pdf">
<cfdocument format="pdf" bookmark="true">
I get the same behavior as the first code snippet.
I know how to get the browser to request a download, rather than displaying an inline string, and everything works as expected, but this is not the desired behavior.
I need to use time and dates in file names, and end users do not understand enough to not overwrite their files (if they want to save them).
Is there something I'm missing that will force IE and Firefox to do what they should? What other browsers will do this? Mobile Safari?