【发布时间】:2012-10-29 14:53:59
【问题描述】:
我有一个页面,我只是想在屏幕上写一个 pdf。这就是我正在做的事情:
protected void ViewPDF(string url)
{
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.TransmitFile(url);
Response.Flush();
Response.End();
}
这适用于除 Mac 上的 Firefox 之外的所有浏览器和操作系统。浏览器不会在浏览器中显示 pdf 文件,而是打开对话框下载文件,您可以在其中打开或保存。
我也试过这个:
protected void ViewPDF(string url)
{
Response.Clear();
Response.ContentType = "application/pdf";
string path = Server.MapPath(url);
byte[] data = File.ReadAllBytes(path);
Response.BinaryWrite(data);
Response.End();
}
我得到了同样的结果。
有人知道如何解决这个问题吗?
【问题讨论】:
-
Firefox 是否有 pdf 查看器插件? FF 本身没有原生的 pdf 处理工具,所以如果没有查看器插件,除了下载提示之外,你永远不会得到任何东西。
标签: c# asp.net macos firefox pdf