如何在红宝石中使用pdf查看器 [英] How to have pdf viewer in ruby

查看:119
本文介绍了如何在红宝石中使用pdf查看器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能将PDF阅读器嵌入到ruby中?

How can I embeded pdf viewer in ruby on rail?

现在我试过
< embed src =MyPdfDocument。 pdfwidth =500height =375>
但它不起作用。
$ b

Now I tried <embed src="MyPdfDocument.pdf" width="500" height="375"> but it doesn't work. I used firebug and see the error like this


[Exception ...]组件返回的失败代码:0x80004005(NS_ERROR_FAILURE)[nsIStreamListener.onStopRequest ]nsresult:0x80004005(NS_ERROR_FAILURE)location:JS frame :: file:///home/bengasi/.mozilla/firefox/cmb1mbzu.default/extensions/firebug@software.joehewitt.com/components/firebug-channel -listener.js :: anonymous :: line 167data:no]
[Break on this error] this.listener.onStopRequest(request,requestContext,statusCode); \\\

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIStreamListener.onStopRequest]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///home/bengasi/.mozilla/firefox/cmb1mbzu.default/extensions/firebug@software.joehewitt.com/components/firebug-channel-listener.js :: anonymous :: line 167" data: no] [Break on this error] this.listener.onStopRequest(request, requestContext, statusCode);\n

firebug -... stener.js(line 167)

firebug-...stener.js (line 167)


推荐答案

如果您试图将PDF作为图像显示,并包含HTML内容,那么浏览器不会这样做,而您的问题在于浏览器,而不是Ruby on Rails。您可以链接到PDF,并将其全部显示出来,但不能将其嵌入到其他文档中。

If you are trying to display a PDF as an image, surrounded by HTML content... then a browser won't do that, and your problem is with the browser, not Ruby on Rails. You can link to a PDF, and display it whole, but you cannot embed it in another document.

您可以模拟效果(可能在某些浏览器中) iFrame,但这是一个HTML问题,而不是rails问题......并且您可能会花费大量时间使其在所有浏览器中都可用。

You could simulate the effect (maybe, in some browsers) with an iFrame, but that is a HTML question, not a rails question... and you would possibly spend a lot of time making it work in all browsers.

这篇关于如何在红宝石中使用pdf查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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