是否可以使用URL参数链接到PDF中的书签?


82

在网站上提供指向PDF文件的链接时,是否可以在URL中包含信息(请求参数),这会使PDF浏览器插件(如果使用)跳到特定的书签,而不仅仅是在开始时打开?

像这样的东西:http : //www.somehost.com/user-guide.pdf ? bookmark= chapter3吗?

如果没有书签,是否可以转到特定页面?

我假设如果有答案,它可能特定于Adobe的PDF阅读器插件或某些东西,并且可能有版本限制,但是我最感兴趣的是该技术是否存在。

Answers:


78

是的,您可以按编号或命名位置链接到特定页面,并且如果用户的浏览器使用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中创建目标,请执行以下操作:

  1. 手动浏览PDF至所需位置
  2. 转到查看>导航选项卡>目的地
  3. 在选项下,选择扫描文档
  4. 完成此操作后,从“选项”菜单中选择“新目的地”,然后输入适当的名称

16
重要说明:命名目的地不是书签。您可以使用Adobe Acrobat(完整,而不是阅读器!)及其导航面板“目的地”添加命名的目的地。我不知道如何直接链接到书签。没有记录的url参数。
eFloh 2011年

我知道这是一个老问题。但是我想知道是否有人在.net代码中构建pdf时不知道如何将命名目的地添加到pdf中。我们正在使用动态pdf组件在.net中创建pdf:s。动态pdf不支持添加命名目标。
mortb

1
它与相对引用,如不工作somedir/my.pdf#page=3,和PDF-Xchange的浏览器(从创建my.docx通过另存为PDF ..MS Office专业增强版2010 / 14.0.7116.5000
安德烈亚斯·迪特里希

2
看来,一个简单的锚标记至少在chrome v57中适用于“书签”。因此,像<a href=" example.com/file.pdf#mybookmark">链接文本</a>之类的链接适用于chrome v57(我想是或更高)
Kemal Erdogan

16

RFC 3778第3节指定了可与PDF文件一起使用的“片段标识符”,其中包括nameddest和page。


11

有多个查询参数可以处理。完整清单如下:

资源

+-------------------------+----------------------------------------------------------------------------------------------+------------------------------------------------------+
| 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岁了……
Greg Dubicki

2
@GregDubicki嗨,格雷格,我认为不可能有一个新的,如果他们会发布新类型的pdf(例如pdfx),可能会有一个...我想这取决于处理url的机制...。
Matas Vaitkevicius


7

值得补充的是,韦恩的解决方案可以用于:

  • Chrome(自2011年起第14版,请参见此问题以了解详细信息)(已在第44版进行测试),
  • Firefox(经过40版测试),
  • 歌剧(第31节经过测试),

...但是它不适用于:

  • Safari(第8版)(但Apple的Safari Bug跟踪器中对此功能有要求)

您是否有有关IE如何处理pdf深层链接的信息?
TeeJaay 2015年

不,我的计算机上没有IE可以对其进行测试,对不起@TeeJaay。
Greg Dubicki '16
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.