Wrong Filename when saving a PDF file from Browser to Disk

Robert

New member
Joined
Jul 4, 2003
Messages
1
Location
Kazakhstan
Hi,
for a Web-Application i need to display pdf-files in a browser using
Response.Clear()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.BinaryWrite(DokData) or
Response.WriteFile(FilePath)
Response.End()

the File is displayed but when I want to save the file from the browser to the lokal disk in the save-dialog the filename is not correct. Instead its the name of the aspx-page with the pdf-extension (e.g. myASPXPage.pdf).

Its found that its possible to force a download by adding
Response.AppendHeader("Content-Disposition", "attachment; filename=myPDFFile.pdf")
but i need to display the file...

How can i get the correct filename into the save-dialog?
Thanks for your help!
 
I have a clumsy solution that will work ;)

1.) Have a primary script that copies your PDF output script to a new file with the correct PDF name.
2.) Re-direct to the PDF output page.

Example:

InBetween.aspx
Copies and Renames
PDF.aspx
To
ThisPDFDocument

Therefore download reads:

ThisPDFDocument.pdf

Its not clean, but it would work - good luck :P
 
Back
Top