与PDF填充的Iframe - 使用MVC [IE问题] [英] Populating Iframe with PDF - Using MVC [IE Issue]

查看:191
本文介绍了与PDF填充的Iframe - 使用MVC [IE问题]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我有填充的iframe,我有一个PDF文档的一个问题,但这个问题只发生在IE浏览器。

Currently, I have an issue with populating an iframe that I have with a PDF document, but this issue only occurs in IE.

基本布局:

我有一个包含项目(附件),其可以是图片,文本或pdf的列表的屏幕。当用户点击这些项目之一 - 它将使到一个控制器动作[ViewAttachment]将返回所要求的项目,并在iframe中显示它的调用

I have a screen that contains a list of items (attachments), which can be images, text or pdf. When the user clicks on one of these items - it will make a call to a controller action [ViewAttachment] which will return the requested item and display it in the iframe.

这当前适用于所有数据类型,在IE浏览器的PDF文件除外。 (火狐,Chrome等方面都显示没有问题iframe的PDF)。

This currently works for all data types with the exception of PDFs in IE. (Firefox, Chrome etc. all display the PDF in the iframe without issue.)

我previously使用ADOBE READER 9,最近在解决这一问题的希望升级到10。我会附加一些code,看看是否有人有任何建议,如何可能解决这个问题。

I previously was using Adobe Reader 9, and recently upgraded to 10 in hopes of solving this issue. I'll attach some code to see if anyone has any suggestions as to how to possibly resolve this.

code来填充的iframe:(移动到两行可读性)

$(".viewattachment").live('click',function () 
{ 
   $("iframe#test").attr("src","<%=Url.Action("ViewAttachment","Images") %>?
   attachment=" + $(this).next().val());
}); 

ViewAttachment控制器动作:

public ActionResult ViewAttachment(string attachmentGuid)
{
      Attachment attachment= imageAgent.GetAttachment(attachmentGuid);

      Stream resultStream = new MemoryStream();
      resultStream =  StorageProviders[attachment.ProviderName]
                      .ReadFile(attachment.FileReference);

      resultStream.Position = 0;
      FileStreamResult result = new FileStreamResult(resultStream, 
                                                     attachment.ContentType);

      return result;
}

注:


  • 我已经尝试切换显示PDF在浏览器中在Adobe Reader没有任何成功。

  • 目前正在测试这种对IE8。

  • 当在PDF查看点击 - iframe的只是保持在它的previous内容和根本不更改

推荐答案

在几种不同的方法和测试迭代 - 我确定这是IE8-9和Adobe Reader 9-10版本之间有冲突。我增加了以下meta标签包含iframe的窗口,它解决了所有的问题:

After several different methods and iterations of testing - I determined that it was a conflict between IE8-9 and versions of Adobe Reader 9-10. I added the following meta tag to the window containing the iframe and it resolved all of the issues:

<meta http-equiv="X-UA-Compatible" content="IE=7" />

这至少应该工作,直到更新/修复而成。

This should at least work until an update / fix is made.

这篇关于与PDF填充的Iframe - 使用MVC [IE问题]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆