Hi All,
I am outputting my PDF to the browser using Response. Its all working perfectly except I cant get the PDF to use the filename I want it to - it always comes up with a few random numbers/letters. I have tried using
Code:
Response.AddHeader("Content-Disposition", "inline;filename=myPDFFilename.pdf")
when creating the PDF, but it doesnt seem to make any difference in Firefox, but works in IE 7...
here is the code in my save function:
Code:
protected void savePDF(PdfDocument pdfDocument)
{
// Send PDF to browser
MemoryStream stream = new MemoryStream();
pdfDocument.Save(stream, false);
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "inline;filename=myPDFFilename.pdf");
Response.AddHeader("content-length", stream.Length.ToString());
Response.BinaryWrite(stream.ToArray());
Response.Flush();
stream.Close();
Response.End();
}
Can I set a property of the PdfDocument object I am saving which will also set the filename? or does it have to be specifically in the Response.AddHeader()?
Also, if i change the "inline" to "attachment", the filename i set appears in the save as dialog, even in FF!
Mike