是否可以使用 URL 参数链接到 PDF 中的书签?
Posted
技术标签:
【中文标题】是否可以使用 URL 参数链接到 PDF 中的书签?【英文标题】:Is it possible to link to a bookmark within a PDF using URL parameters? 【发布时间】:2010-09-12 15:25:31 【问题描述】:在网站上提供指向 PDF 文件的链接时,是否可以在 URL 中包含信息(请求参数),这将使 PDF 浏览器插件(如果使用)跳转到特定的书签,而不仅仅是在开始?
类似:http://www.somehost.com/user-guide.pdf?bookmark=chapter3 ?
如果不是书签,是否可以转到特定页面?
我假设如果有答案,它可能特定于 Adobe 的 PDF 阅读器插件或其他东西,并且可能有版本限制,但我最感兴趣的是该技术是否存在。
【问题讨论】:
【参考方案1】:值得补充的是,Wayne's solution 也工作:
Chrome(自 2011 年第 14 版起,请参阅this issue 了解详情)(已在第 87 版和第 44 版测试), Firefox(在 v. 84.0.1 和 v. 40 上测试), Opera(在 v. 73 和 v. 31 上测试), Safari(在 v. 14.0.2 上测试,它在 v. 8 上无法运行),(更新到 2021 年 1 月的当前版本。)
【讨论】:
你有任何关于 IE 如何处理 pdf 深层链接的信息吗? 不,我的机器上没有 IE 来测试它,对不起@TeeJaay。【参考方案2】:RFC 3778 section 3 指定可用于 PDF 文件的“片段标识符”,包括 nameddest 和 page。
【讨论】:
【参考方案3】:可以处理多个查询参数。 完整列表如下:
Source
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| Syntax | Description | Example |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| nameddest=destination | Specifies a named destination in the PDF document | http://example.org/doc.pdf#Chapter6 |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| page=pagenum | Specifies a numbered page in the document, using an integer | http://example.org/doc.pdf#page=3 |
| | value. The document’s first page has a pagenum value of 1. | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| comment=commentID | Specifies a comment on a given page in the PDF document. Use | #page=1&comment=452fde0e-fd22-457c-84aa- |
| | the page command before this command. | 2cf5bed5a349 |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| collab=setting | Sets the comment repository to be used to supply and store | #collab=DAVFDF@http://review_server/Collab |
| | comments for the document. This overrides the default comment | /user1 |
| | server for the review or the default preference. The setting is of the | |
| | form store_type@location, where valid values for store_type are: | |
| | ● DAVFDF (WebDAV) | |
| | ● FSFDF (Network folder) | |
| | ● DB (ADBC) | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| zoom=scale | Sets the zoom and scroll factors, using float or integer values. For | http://example.org/doc.pdf#page=3&zoom=200,250,100 |
| zoom=scale,left,top | example, a scale value of 100 indicates a zoom value of 100%. | |
| | Scroll values left and top are in a coordinate system where 0,0 | |
| | represents the top left corner of the visible page, regardless of | |
| | document rotation | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| view=Fit | Set the view of the displayed page, using the keyword values | http://example.org/doc.pdf#page=72&view=fitH,100 |
| view=FitH | defined in the PDF language specification. For more information, | |
| view=FitH,top | see the PDF Reference. | |
| view=FitV | Scroll values left and top are floats or integers in a coordinate | |
| view=FitV,left | system where 0,0 represents the top left corner of the visible | |
| view=FitB | page, regardless of document rotation. | |
| view=FitBH | Use the page command before this command. | |
| view=FitBH,top | | |
| view=FitBV | | |
| view=FitBV,left | | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| viewrect=left,top,wd,ht | Sets the view rectangle using float or integer values in a | |
| | coordinate system where 0,0 represents the top left corner of the | |
| | visible page, regardless of document rotation. | |
| | Use the page command before this command. | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| pagemode=bookmarks | Displays bookmarks or thumbnails. | http://example.org/doc.pdf#pagemode=bookmarks&page=2 |
| pagemode=thumbs | | |
| pagemode=none | | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| scrollbar=1|0 | Turns scrollbars on or off | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| search=wordList | Opens the Search panel and performs a search for any of thewords in the specified word list. | #search="word1 word2" |
| | The first matching word ishighlighted in the document. | |
| | The words must be enclosed in quotation marks and separated byspaces. | |
| | You can search only for single words. You cannot search for a string of words. | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| toolbar=1|0 | Turns the toolbar on or off. | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| statusbar=1|0 | Turns the status bar on or off. | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| messages=1|0 | Turns the document message bar on or off. | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| navpanes=1|0 | Turns the navigation panes and tabs on or off. | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| highlight=lt,rt,top,btm | Highlights a specified rectangle on the displayed page. Use the | |
| | page command before this command. | |
| | The rectangle values are integers in a coordinate system where | |
| | 0,0 represents the top left corner of the visible page, regardless of | |
| | document rotation | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| fdf=URL | Specifies an FDF file to populate form fields in the PDF file beingopened. | #fdf=http://example.org/doc.fdf |
| | Note: The fdf parameter should be specified last in a URL. | |
+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
【讨论】:
很高兴你找到了完整的文档,@Matas。但是没有更新的文档可用吗?这个大概10岁了…… @GregDubicki 嗨,格雷格,我认为不会有新的,如果他们会发布新类型的 pdf(如 pdfx)可能会有一个......取决于处理机制的位置网址是我想....【参考方案4】:是的,您可以通过编号或指定位置链接到特定页面,并且如果用户的浏览器使用 Adobe Reader 作为查看 PDF 文件的插件,这将始终有效。
对于特定页面的编号:
<a href="http://www.domain.com/file.pdf#page=3">Link text</a>
对于一个命名的位置(目的地):
<a href="http://www.domain.com/file.pdf#nameddest=TOC">Link text</a>
使用 Acrobat 在 PDF 中创建目标:
-
在 PDF 中手动导航到所需位置
转到视图 > 导航选项卡 > 目的地
在选项下,选择扫描文档
完成后,从“选项”菜单中选择“新建目的地”并输入适当的名称
【讨论】:
重要提示:命名目的地不是书签。您可以使用 adobe acrobat(完整,而不是阅读器!)及其导航面板“destinations”添加命名目的地。我不知道如何直接链接到书签。没有记录的 url 参数。 我知道这是一个老问题。但我想知道在.net 代码中构建 pdf 时是否有人知道如何将命名目的地添加到 pdf 中。我们正在使用组件动态 pdf 在 .net 中创建我们的 pdf:s。动态 pdf 不支持添加命名目标。 它不适用于相对引用,例如somedir/my.pdf#page=3
和 PDF-XChange Viewer(通过 MS Office Professional 的 Save As ..pdf 从 my.docx 创建加 2010 / 14.0.7116.5000)
似乎一个简单的锚标记适用于“书签”,至少适用于 chrome v57。所以像 example.com/file.pdf#mybookmark">Link text 这样的链接适用于 chrome v57(或更高版本,我想)【参考方案5】:
PDF Open Parameters 记录了您可以使用的可用 URL 片段。
【讨论】:
以上是关于是否可以使用 URL 参数链接到 PDF 中的书签?的主要内容,如果未能解决你的问题,请参考以下文章
手把手教你为 PDF文件/论文自动批量添加书签/目录, 彻底告别手动添加书签的烦恼