Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8270239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:31:30+00:00 2026-06-08T06:31:30+00:00

I am trying to dynamically create an inline PDF that, when the user chooses

  • 0

I am trying to dynamically create an inline PDF that, when the user chooses to save it, prompts with my custom filename. According to the documentation, the saveasname attribute should do what I want.

(format=”PDF” only) The filename that appears in the SaveAs dialog when a user saves a PDF file written to the browser.

However, what is happening in both IE 9 and in Firefox 13.0.1 is that the filename that appears in the SaveAs dialog is the same as my CF template, but with a PDF extension. (In other words, my code is in makepdf.cfm and the SaveAs prompts me to save makepdf.pdf.) In Chrome, however, it works perfectly. (All on Windows 7.)

Here is my code to create the PDF:

<cfdocument format="pdf" bookmark="true" saveasname="MyReport.pdf">

If I explicitly declare the content disposition and content type, like so

<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 declared twice
  • Firefox tells me the PDF file is corrupt
  • IE just ignores it (and still doesn’t show the right filename)

If I just rely on the header

<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 snippet of code.

I know how to get the browser to prompt for download rather than displaying inline, and everything works as expected then, but that’s not the desired behavior.

I need to use times and dates in filenames and the end users are not savvy enough to keep from overwriting their files (should they choose to save them).

Is there something I’m missing that will get IE and Firefox to do what they’re supposed to? What other browsers are going to do this? Mobile Safari?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:31:31+00:00Added an answer on June 8, 2026 at 6:31 am

    The problem seems to be that “filename=xxx” was really intended for the “attachment” disposition, and not all the browser PDF plugins recognise it as a mechanism for specifying the inline “save as”, as you’ve discovered.

    A different approach to getting them all to use your preferred filename would be to manipulate the URL using web server rewrite rules. As a simple example you’d have your script for generating the pdfs and serving them inline: pdf.cfm

    <cfheader name="Content-Disposition" value="inline">
    <cfdocument format="PDF" mimetype="application/pdf">Test</cfdocument>
    

    Then create a re-write rule which matches URLs in the form /pdf/myfilename and passes them to pdf.cfm. On IIS7 this might be:

    <rule name="Inline PDF SaveAs" stopProcessing="true">
        <match url="^/pdf/[\w-]+$" ignoreCase="true" />
        <action type="Rewrite" url="/pdf.cfm" appendQueryString="false" />
    </rule>
    

    This will match filenames containing alphanumeric, underscore and hyphen characters only. You wouldn’t want to allow spaces, or invalid filename characters.

    When you access /pdf/myreport the PDF will be displayed inline by the plugin, and when you save it, the default filename will be myreport.pdf.

    If you’re using a framework which supports Search Engine Safe URLs or “routes”, you could do the same without needing web server rewrites.

    UPDATE: In fact you don’t need to use URL rewriting: simply append a forward slash and then the desired filename to the CF script URL, e.g.

    /pdf.cfm/myreport

    The plugin will use whatever comes after the final slash as the “Save As…” name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to dynamically create a book from code server-side. That part's working fine,
I am trying to dynamically create a list of radio buttons that represents the
I'm trying to dynamically create a PDF using the TCPDF library in a document
I'm trying to dynamically create a PDF (on the server) with some text on
I'm trying to dynamically create domain objects in Grails and encountered the problem that
I'm trying to dynamically create 5 divs that represent 5 days of the week.
I'm trying to dynamically create a navbar from data i fetch from a web
I'm trying to dynamically create alert messages using the jQuery plugin for Bootstrap CSS.
I'm trying to dynamically create a link from a Windows Form to our website
I am trying to dynamically create an XML file using php like this: header

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.