Html 从网页链接到 PDF 文档中的特定部分(锚点)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13427302/
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
Linking from a web page to a specific section (anchor) in PDF document
提问by GreyCat
There is a standard from Adobethat in theory specifies opening PDF documents from a link clicked in a browser in a way to open specific sections (AKA "anchor", "named reference") of PDF document. This functionality should be of great help if one would like to refer to a specific portion of large PDF (such as some standard or specification).
Adobe有一个标准,理论上指定从在浏览器中单击的链接打开 PDF 文档,以打开 PDF 文档的特定部分(又名“锚点”、“命名参考”)。如果您想参考大型 PDF 的特定部分(例如某些标准或规范),此功能应该会很有帮助。
However, from what I see now, support for this standard is close to non-existent.
然而,从我现在看到的情况来看,对这个标准的支持几乎不存在。
For example, these links should open Scala Reference PDF at section 3.2.6, "Annotated Types":
例如,这些链接应该在第 3.2.6 节“注释类型”中打开 Scala 参考 PDF:
- http://www.scala-lang.org/docu/files/ScalaReference.pdf#subsection.3.2.6
- http://www.scala-lang.org/docu/files/ScalaReference.pdf#nameddest=subsection.3.2.6
- http://www.scala-lang.org/docu/files/ScalaReference.pdf#page=23
- http://www.scala-lang.org/docu/files/ScalaReference.pdf#subsection.3.2.6
- http://www.scala-lang.org/docu/files/ScalaReference.pdf#nameddest=subsection.3.2.6
- http://www.scala-lang.org/docu/files/ScalaReference.pdf#page=23
(Techincally, variant #3 should open page #23, which is essentially the same destination)
(从技术上讲,变体 #3 应该打开页面 #23,这基本上是相同的目的地)
Is there a working way (may be with a couple of shims, proprietary wrappers or whatever else) to make this work on majority of systems? What is the usage share of Adobe Reader plugin, should I care about other systems?
是否有一种工作方式(可能使用一些垫片、专有包装器或其他任何东西)来使这项工作在大多数系统上工作?Adobe Reader插件的使用份额是多少,我应该关心其他系统吗?
If it's not possible, at least I'd like to find a working solution for every platform (i.e. Windows, Linux, Mac) that I could recommend to my site's users if they want to be able to use named destination links.
如果不可能,至少我想为每个平台(即 Windows、Linux、Mac)找到一个可行的解决方案,如果他们希望能够使用命名的目标链接,我可以向我的网站用户推荐这些解决方案。
From what I've tested:
从我测试过的:
- Windows, MSIE/Firefox/Chrome, Adobe Acrobat Reader plugin - all variants work with version 9+, but:
- MSIE has a weird caching issue (i.e. anchor does not work until document was cached)
- Older versions do not work
- It has issues with link format: generally, it should be regular absolute link to a real web server, starting with "http://". Relative links, samba-style links (
\\HOST\dir\file.pdf#something
), anything else besides "http" (or probably, "https") scheme won't work
- Windows, any browsers set up to run Adobe Acrobat Reader as a separate process - does not work
- Windows, any browsers, FoxIt Reader - does not work
- Windows, any browsers, CutePDF - does not work
- Linux/Konqueror/Okular - only variant #1 works
- Linux, any other browsers set up to run Okular or any other PDF viewer as external process - does not work (as browser does not pass any "#arguments" in a command line)
- Any OS, Firefox 15+ PDF.js internal PDF viewer- does not work
- Windows、MSIE/Firefox/Chrome、Adobe Acrobat Reader 插件 - 所有变体都适用于 9+ 版本,但是:
- MSIE 有一个奇怪的缓存问题(即锚点在文档被缓存之前不起作用)
- 旧版本不起作用
- 它存在链接格式问题:通常,它应该是到真实 Web 服务器的常规绝对链接,以“http://”开头。相对链接、samba 风格的链接 (
\\HOST\dir\file.pdf#something
)、除了“http”(或者可能是“https”)方案之外的任何其他内容都不起作用
- Windows,任何设置为将 Adobe Acrobat Reader 作为单独进程运行的浏览器 - 都不起作用
- Windows、任何浏览器、FoxIt Reader - 不工作
- Windows,任何浏览器,CutePDF - 不起作用
- Linux/Konqueror/Okular - 只有变体 #1 有效
- Linux,设置为运行 Okular 或任何其他 PDF 查看器作为外部进程的任何其他浏览器 - 不起作用(因为浏览器不会在命令行中传递任何“#arguments”)
- 任何操作系统、Firefox 15+ PDF.js 内部 PDF 查看器- 不起作用
I'd appreciate if you'd try it to test in various different combinations.
如果您尝试以各种不同的组合进行测试,我将不胜感激。
回答by Jukka K. Korpela
What seems to work in general is variant #4 but using the number of the page as in actual division into pages in the PDF document, in this case
似乎通常有效的是变体 #4,但在这种情况下,使用页面数作为实际划分为 PDF 文档中的页面
http://www.scala-lang.org/docu/files/ScalaReference.pdf#page=31
http://www.scala-lang.org/docu/files/ScalaReference.pdf#page=31
The PDF document has page numbers that start from the content proper, after the table of content, but that numbering differs from the one to be used in #page=...
PDF 文档的页码从内容本身开始,在目录之后,但该编号与 #page=... 中使用的编号不同。