views:

22

answers:

2

After submitting a form, the user is presented with a link to a pdf document. The link is straight to the document, it is not streamed.

If the user right-clicks and chooses 'save link as,' the document saves and opens fine. However, if the user just clicks on the link, the browser takes a very long time to respond (I'm going to guess it's 3 minutes) and then adobe reader gives the following error:

"the file is damaged and could not be repaired"

This is in Chrome v5, ASP.NET 3.5 and the link is returned inside an UpdatePanel.

A: 

it depends on browser settings that are configured for PDF Links. If you change the settings in broweser, you will get the download dialog.

Mozilla Firefox

  1. Open Mozilla Firefox
  2. Click Tools and then Options
  3. Within the Options window click Applications
  4. Select the Content Type you wish to adjust. For example, if you want to change how a .PDF file opens in Firefox, select Adobe Acrobat Document.
  5. In the Action section, change the action to how you wish to open the file. If you want to download .PDF files instead of opening them, select Save file.

Internet Explorer:

You have to right click and click save target as to download.

The other option is, create a seperate asp.net and write below code to download the PDF

private void Page_Load(object sender, System.EventArgs e)
{
  //Set the appropriate ContentType.
  Response.ContentType = "Application/pdf";
  //Get the physical path to the file.
  string FilePath = MapPath("acrobat.pdf");
  //Write the file directly to the HTTP content output stream.
  Response.WriteFile(FilePath);
  Response.End();
}
Jeeva S
Cheers Jeeva. I am curious though, this is behaviour that is specific to my implementation, not to pdfs in general. If I click on a link to a pdf anywhere else, it will open correctly, just not within this update panel.
Pete
A: 

I've had this issue before and the cause was the PDF itself.

Adobe has a slew of causes for this: http://kb2.adobe.com/cps/328/328233.html

FWIW, my PDf issue was solved by opening the PDF in Adobe and going to Document -> Reduce File Size -> Make Compatible with Version 7. (current version - 2)

Nick Canzoneri