PDF 不显示在 Safari iPad 中

PDF is not display in safari i-Pad

在我的 asp.net MVC 网络应用程序中,我需要在 iPad 的 safari 浏览器中显示 pdf。我的代码是这样的。

 <object data="@Model.StringPdfUrl" type="application/pdf">
                <embed src="@Model.StringPdfUrl" type="application/pdf" />
            </object> 

有人知道这个问题的解决方法吗?

先谢谢你

我找到了解决方案。

我在 safari 中使用 iframe 渲染 pdf

 if (Request.Browser.Type.Contains("Safari"))
                    {
        <iframe src="@Model.StringPdfUrl" height="750" width="600" frameborder="0" id="myiframe" ></iframe>
                    }
                    else
                    {
        <object height="750" width="600" data="@Model.StringPdfUrl" type="application/pdf">
            <embed src="@Model.StringPdfUrl" type="application/pdf" />
        </object> 
                    }

我想知道这是否不是我曾经遇到过的 Internet Explorer 问题。

即使使用最新的 IE 11,如果 url 不以扩展名 .pdf 结尾(我的 MVC 应用就是这种情况:url 就像 /File/Download/4587),则IE插件无法渲染PDF文件。 <embed> 同样的问题。

我尝试了 iframe 解决方案,但在某些计算机上文档以新 window 打开。

最终我实现的解决方案是将PDF文档的每一页都转为GhostscriptSharp的图片,然后在HTML页面中将文档在线渲染为图片(使用导航控件转到 first/previous/next/last 页面)。