制作PDF显示内联,而不是单独的Acrobat Reader窗口 [英] Make PDF display inline instead of separate Acrobat Reader window

查看:492
本文介绍了制作PDF显示内联,而不是单独的Acrobat Reader窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到了从数据库中检索数据,创建一个使用iTextSharp的PDF文件和流的PDF浏览器的ASP.NET ASHX类。浏览器(IE和Firefox至少)推出的Acrobat Reader作为一个单独的窗口中打开该文件。我想为它在浏览器中内嵌显示。

I've got an ASP.NET ashx class that retrieves data from a database, creates a PDF file using iTextSharp, and streams the PDF to the browser. The browser (IE and Firefox at least) is launching Acrobat Reader as a separate window to open the file. I'd like for it to display inline within the browser.

时的东西我完全可以从服务器端控制?我已经设置Content-Type头应用程序/ PDF格式的,我试过设置内容处置和内容长度。没有什么迄今已奏效。

Is that something I can completely control from the server side? I'm already setting the Content-Type header to application/pdf, and I've tried setting Content-Disposition and Content-Length. Nothing so far has worked.

难道还有其他的头我失踪?是否有东西,告诉浏览器如何显示它的PDF本身呢?任何其他的想法?

Is there another header I'm missing? Is there something in the PDF itself that tells the browser how to display it? Any other ideas?

推荐答案

设置内容部署和内容类型标头应该这样做,但你可能还需要调用 Response.ClearHeaders()来清除已设置其他头。

Setting the content-disposition and content-type headers should do it, but you might also need to call Response.ClearHeaders() to clear other headers that have been set.

另外,尝试使用提琴手看到从响应实际的标题和内容,并将它们与那些从一个网站,就像你想要的。

Also, try using Fiddler to see the actual headers and content from the response and compare them to those from a site that works like you want.

这篇关于制作PDF显示内联,而不是单独的Acrobat Reader窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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