Note that there are some explanatory texts on larger screens.

plurals
  1. POChrome PDF Viewer "Save To Disk" feature - is it possible to control saved filename extension?
    text
    copied!<p>In an ASP.NET 2.0 application, using Google Chrome 13 on Windows. </p> <p>My app dynamically generates a PDF report when the user browses to a particular aspx page. For the most part, things work fine on various browsers. </p> <p>However, on Chrome, when Chrome's PDF viewer is being used, the following can happen : - the user presses the floating diskette icon on the bottom right hand side of the viewer to save the PDF document. The file is saved with the aspx page's name. e.g. Report.aspx . </p> <p>If I open that downloaded aspx file in Adobe Reader, it opens up ok as a PDF document. But is there a way to get chrome to default the name of the file to save to have a ".PDF" extension ?</p> <p><strong>EDIT :</strong></p> <p>The code for the report generation page looks something like this :</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { Response.Clear(); Response.ContentType = "application/pdf"; byte[] data = GenerateReportHere(); // dynamically generate PDF report Response.AddHeader("Content-Length", data.Length.ToString()); Response.BinaryWrite(data); Response.Flush(); Response.End(); } </code></pre> <p>Note that I don't want to use a "Content-Disposition" header like : </p> <pre><code> Response.AddHeader("Content-Disposition", "attachment; filename=Report.pdf"); </code></pre> <p>because that causes the browser to ask the user if they want to download the file. In Chrome it won't display it in its PDF viewer - just gives the user the chance after downloading to open the file using whatever program they have associated with the ".pdf" file extension.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload