我试图从数据库(byte [])向用户显示PDF。PDF作为浏览器上的文本
我正在使用下面的代码来呈现PDF。它将PDF格式显示为二进制文本,如下所示。它不是在PDF应用程序中打开,而是将PDF呈现为文本。
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();
更新:只是注意到,这个应用程序页面在Chrome正确渲染PDF,但在IE浏览器仍然显示文本。 (不要在服务器上测试FF3)。可能它的一些浏览器问题?
任何想法? alt text http://img442.imageshack.us/img442/9242/pdfdisplay.jpg
代码位于何处? – 2010-06-01 14:30:58
你使用什么浏览器? – VMAtm 2010-06-01 14:31:56
请参阅我的更新...谢谢。 – spt3210 2010-06-01 15:49:58