Search code examples
c#asp.netpdfmoss

PDF coming as text on browser


I am trying to display a PDF from database (byte[]) to user.

I am using code below to render PDF. It is giving me PDF as binary text as shown below. Instead of open in PDF application it is rendering PDF as text.

Response.Buffer = true;
        Response.Charset = "";
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        //Response.AddHeader("Content-Length", fileToDownload.Length.ToString());
        //Response.AddHeader("Content-Disposition", "inline; name=RemoteUserGuide.pdf");
        Response.AppendHeader("content-length", fileToDownload.Length.ToString());
        Response.ContentType = "application/pdf";
        Response.BinaryWrite(fileToDownload);
        Response.Flush();
        ////Response.Close();
        Response.End();

UPDATE: Just noticed, this application page is rendering PDF correctly in CHROME, but still displaying text in IE. (don't have FF3 on server to test). Probably its some browser issue?

Any Ideas? alt text


Solution

  • Corrupted adobe install does this. reinstall Adobe Reader on the target (client) machine.

    Sometimes the Adobe Installer crashes and does this.