javascript 用于在浏览器中渲染和注释 PDF 文档的 Html5 组件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5225742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 16:26:51  来源:igfitidea点击:

Html5 component for rendering and annotating PDF documents in the browser?

javascriptpdfhtmlpostscript

提问by user648891

I am trying to build a webapp that can view and annotate PDF files in a browser without flash player installed (like an iPad). Are there any free or cheap components that render a PDF in html, JS and canvas? Thanks!

我正在尝试构建一个 web 应用程序,它可以在没有安装 Flash 播放器的浏览器中查看和注释 PDF 文件(如 iPad)。是否有任何免费或廉价的组件可以在 html、JS 和 canvas 中呈现 PDF?谢谢!

回答by jsbueno

Not that I am aware of. (I am assuming you googled for it, so I am skipping that). This is obviously a missing thing for the web -- (I found a toy implementation here: http://ajaxian.com/archives/wps-postscript-and-pdf-interpreter-for-html-5-canvas- but it is just a toy for now).

不是我所知道的。(我假设你用谷歌搜索了它,所以我跳过那个)。这显然是网络缺少的东西 - (我在这里找到了一个玩具实现:http: //ajaxian.com/archives/wps-postscript-and-pdf-interpreter-for-html-5-canvas- 但它是现在只是一个玩具)。

A serious product could adapt Ghostscript itself to Javascript using a project like http://code.google.com/p/emscripten/-- which can compile C code to LLVM and then to javascript. There is an example of the entire Python interpreter built into javascript in this way running here: http://syntensity.com/static/python.html

一个严肃的产品可以使用像http://code.google.com/p/emscripten/这样的项目使 Ghostscript 本身适应 Javascript——它可以将 C 代码编译为 LLVM,然后编译为 javascript。有一个以这种方式运行在 javascript 中的整个 Python 解释器的示例:http: //syntensity.com/static/python.html

Certainly it would not be trivial, and the output part to canvas, and UI, would need to be written anyway. I think it won't fit your needs now, but I am writing it here, so that maybe someone could make this happen.

当然,这不是微不足道的,无论如何都需要编写画布和 UI 的输出部分。我认为它现在不适合您的需求,但我在这里写它,所以也许有人可以做到这一点。

In the mean time, you could consider running Ghostscript (http://pages.cs.wisc.edu/~ghost/doc/intro.htm) server side, and deliver pre-rendered PNG images to the browser. That would be far easier to do, although it would demand a lot of server juice.

同时,您可以考虑运行 Ghostscript ( http://pages.cs.wisc.edu/~ghost/doc/intro.htm) 服务器端,并将预渲染的 PNG 图像传送到浏览器。这样做会容易得多,尽管它需要大量的服务器资源。

回答by martin

I was looking for something similar recently:

我最近在寻找类似的东西:

pdf.js (by Andreas Gal @ mozilla inter alia) is under development with the goal to render PDF directly with HTML5 and JavaScript. It's on github [ https://github.com/andreasgal/pdf.js]

pdf.js(由 Andreas Gal @ mozilla 等)正在开发中,目标是直接使用 HTML5 和 JavaScript 呈现 PDF。它在 github 上 [ https://github.com/andreasgal/pdf.js]

It's worth reading the announcement post and comments (140+) [ http://andreasgal.com/2011/06/15/pdf-js/]

值得阅读公告帖子和评论(140+)[ http://andreasgal.com/2011/06/15/pdf-js/]

回答by John Foley

<iframe src="http://docs.google.com/gview?url=http://domain.com/pdf.pdf&embedded=true" 
style="width:600px; height:500px;" frameborder="0"></iframe>

Google docs allows you to embed PDFs, Microsoft Office Docs, and other applications by just linking to their services with an iframe. Its user-friendly, versatile, and attractive.

Google docs 允许您嵌入 PDF、Microsoft Office Docs 和其他应用程序,只需使用 iframe 链接到它们的服务即可。其用户友好、通用且有吸引力。

回答by lsaintj

It depends on what "cheap" means, but I was looking for the same thing and think this HTML5 plugin for flexpaper could be a huge help, at least in terms of a starting place!

这取决于“便宜”是什么意思,但我一直在寻找同样的东西,并认为这个用于 flexpaper 的 HTML5 插件可能是一个巨大的帮助,至少在一个起点方面!

http://devaldi.com/annotations/index_html5.html

http://devaldi.com/annotations/index_html5.html

Actually just kidding. This is EXACTLY what I was looking for (3 hour later) Hope it helps! http://websanova.com/plugins/paint#websanova

其实只是开玩笑。这正是我要找的(3 小时后)希望它有帮助!http://websanova.com/plugins/paint#websanova