Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 it's the name of the aspx-page with the pdf-extension (e.g. myASPXPage.pdf).

 

It's found that it's 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?

Thank's for your help!

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...