简体   繁体   English

使用XULRunner时如何在SWT浏览器窗口中打开pdf文件?

[英]How can I open pdf files in SWT browser window while using XULRunner?

I am working on an eclipse based application wherein I need to preview pdf documents as part of a functionality. 我正在开发基于Eclipse的应用程序,其中我需要预览pdf文档作为功能的一部分。 As of now clicking on preview button opens a prompt for saving the pdf but it does not directly open the document in the required window. 到目前为止,单击“预览”按钮会打开一个提示,用于保存pdf,但不会在所需窗口中直接打开文档。 Is there any way where I can add any arguments/Plugins in the XULRunner or the application's ini file so that the pdf can be opened in the window itself by default ? 有什么方法可以在XULRunner或应用程序的ini文件中添加任何参数/插件,以便默认情况下可以在窗口中打开pdf? (I am using Red Hat Linux 6.5 (Santiago)) (我正在使用Red Hat Linux 6.5(圣地亚哥))

The following applies to Linux only. 以下内容仅适用于Linux。 First of all, your SWT version must be < Eclipse 4.8, see https://www.eclipse.org/swt/faq.php#browserlinux 首先,您的SWT版本必须为<Eclipse 4.8,请参见https://www.eclipse.org/swt/faq.php#browserlinux

If your SWT meets this criterion, there's 2 options I know of: 如果您的SWT符合此标准,我知道有2种选择:

Add plugin nppdf.so to your xulrunner install, needs Adobe Reader "acroread" executable with matching version on the PATH (maybe acroread version can be > nppdf version, not sure about that) 将插件nppdf.so添加到您的xulrunner安装中,需要在PATH上具有匹配版本的Adobe Reader“ acroread”可执行文件(也许acroread版本可以是> nppdf版本,对此不确定)

Use pdf.js: I got it to work using SWT from Eclipse 3.8.2, xulrunner 10.0.4esr and pdf.js < 2, eg 1.10.100. 使用pdf.js:我使用Eclipse 3.8.2,xulrunner 10.0.4esr和pdf.js <2,例如1.10.100的SWT来工作。

UPDATE: this combination of versions has a problem with images in pdf-files, so I had to upgrade to: SWT 4.4 and xulrunner 24. pdf.js 1.10.100 still worked, 2.x would now also be usable, though. 更新:版本的这种组合在pdf文件中存在图像问题,因此我不得不升级到:SWT 4.4和xulrunner24。pdf.js 1.10.100仍然有效,不过2.x现在也可以使用。

In your xulrunner install, create file defaults/preferences/prefs.js (xulrunner.js also works), containing this line: 在您的xulrunner安装中,创建文件defaults / preferences / prefs.js(xulrunner.js也可以),其中包含以下行:

pref("security.fileuri.strict_origin_policy", false);

To view a pdf file, point your swt-embedded xul-runner to 要查看pdf文件,请将嵌入了swt的xul-runner指向

file:///<pdf.js-dir>/web/viewer.html?file=<absolute-pdf-file-path>

This may apply: 这可能适用:

However, we do ask if you plan to embed the viewer in your own site, that it not just be an unmodified version. 但是,我们确实会询问您是否打算将查看器嵌入您自己的网站中,而不只是将其修改为未经修改的版本。 Please re-skin it or build upon it. 请重新设置外观或在其上构建外观。

https://mozilla.github.io/pdf.js/getting_started/#download https://mozilla.github.io/pdf.js/getting_started/#download

Sources: 资料来源:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM