跳转至

12.3 文档级导航

12.3 Document-Level Navigation

12.3.1 概述

12.3.1 General

本小节所描述的功能允许符合标准的阅读器以两种形式之一向用户展示文档的交互式全局概览:

  • 以分层大纲的形式展示文档的内部结构
  • 以一系列缩略图的形式呈现文档各页的缩略视图

大纲中的每个条目或每张缩略图都可以与文档中的一个对应目标位置相关联,这样用户就可以通过点击鼠标直接跳转到该目标位置 。

The features described in this sub-clause allow a conforming reader to present the user with an interactive, global overview of a document in either of two forms:

  • As a hierarchical outline showing the document’s internal structure
  • As a collection of thumbnail images representing the pages of the document in miniature form

Each item in the outline or each thumbnail image may be associated with a corresponding destination in the document, so that the user can jump directly to the destination by clicking with the mouse.

12.3.2 目的地

12.3.2 Destinations

12.3.2.1 概述

12.3.2.1 General

目标位置定义了文档的一种特定视图,包含以下内容:

  • 应显示的文档页面
  • 文档窗口在该页面上的位置
  • 缩放因子

目标位置可与大纲条目(见12.3.3文档大纲”)、批注(12.5.6.5链接批注”)或动作(12.6.4.2跳转动作”和12.6.4.3远程跳转动作”)相关联。在每种情况下,目标位置都指定了在打开大纲条目或批注或执行动作时应呈现的文档视图。此外,文档目录中的可选 OpenAction 条目(见7.7.2“文档目录”)可指定在打开文档时应显示的目标位置。目标位置可通过定义其属性的参数数组显式指定,也可通过名称间接指定 。

A destination defines a particular view of a document, consisting of the following items:

  • The page of the document that shall be displayed
  • The location of the document window on that page
  • The magnification (zoom) factor

Destinations may be associated with outline items (see 12.3.3, “Document Outline”), annotations (12.5.6.5, “Link Annotations”), or actions (12.6.4.2, “Go-To Actions” and 12.6.4.3, “Remote Go-To Actions”). In each case, the destination specifies the view of the document that shall be presented when the outline item or annotation is opened or the action is performed. In addition, the optional OpenAction entry in a document’s catalogue (7.7.2, “Document Catalog”) may specify a destination that shall be displayed when the document is opened. A destination may be specified either explicitly by an array of parameters defining its properties or indirectly by name.

12.3.2.2 明确目的地

12.3.2.2 Explicit Destinations

表 151 展示了在 PDF 文件中显式指定目标位置的允许语法形式。在每种情况下,page 是对页面对象的间接引用(远程跳转动作除外;见12.6.4.3远程跳转动作”)。所有坐标值(左、右、上和下)均应以默认用户空间坐标系表示。页面的边界框是包含其所有内容的最小矩形。(如果边界框的任何一边位于页面裁剪框之外,则使用裁剪框相应的边;有关裁剪框的更多讨论,请见14.11.2页面边界” 。)

对于与远程跳转动作相关联的目标位置(见12.6.4.3远程跳转动作”),不能指定页面对象,因为目标页面位于不同的 PDF 文档中。在这种情况下,page 参数指定的是远程文档中的整数页码,而非当前文档中的页面对象。

表 151 – 目标位置语法
语法 含义
[ page /XYZ left top zoom ] 显示由 page 指定的页面,坐标 (left, top) 位于窗口左上角,并且页面内容按 zoom 因子放大。left、top 或 zoom 参数的值为 null 表示保留该参数的当前值不变。zoom 值为 0 的含义与 null 值相同。
[ page /Fit ] 显示由 page 指定的页面,页面内容放大到刚好能使整个页面在窗口中水平和垂直方向都完全显示。如果所需的水平和垂直放大因子不同,则使用两者中较小的那个,并在另一个维度上将页面居中显示在窗口内。
[ page /FitH top ] 显示由 page 指定的页面,垂直坐标 top 位于窗口上边缘,并且页面内容放大到刚好能使整个页面宽度在窗口内完全显示。top 参数的值为 null 表示保留该参数的当前值不变。
[ page /FitV left ] 显示由 page 指定的页面,水平坐标 left 位于窗口左边缘,并且页面内容放大到刚好能使整个页面高度在窗口内完全显示。left 参数的值为 null 表示保留该参数的当前值不变。
[ page /FitR left bottom right top ] 显示由 page 指定的页面,页面内容放大到刚好能使由坐标 left、bottom、right 和 top 所指定的矩形在窗口中水平和垂直方向都完全显示。如果所需的水平和垂直放大因子不同,则使用两者中较小的那个,并在另一个维度上将矩形居中显示在窗口内。
[ page /FitB ] (PDF 1.1)显示由 page 指定的页面,页面内容放大到刚好能使其边界框在窗口中水平和垂直方向都完全显示。如果所需的水平和垂直放大因子不同,则使用两者中较小的那个,并在另一个维度上将边界框居中显示在窗口内。
[ page /FitBH top ] (PDF 1.1)显示由 page 指定的页面,垂直坐标 top 位于窗口上边缘,并且页面内容放大到刚好能使其边界框的整个宽度在窗口内完全显示。top 参数的值为 null 表示保留该参数的当前值不变。
[ page /FitBV left ] (PDF 1.1)显示由 page 指定的页面,水平坐标 left 位于窗口左边缘,并且页面内容放大到刚好能使其边界框的整个高度在窗口内完全显示。left 参数的值为 null 表示保留该参数的当前值不变。

Table 151 shows the allowed syntactic forms for specifying a destination explicitly in a PDF file. In each case, page is an indirect reference to a page object (except in a remote go-to action; see 12.6.4.3, “Remote Go-To Actions”). All coordinate values (left, right, top, and bottom) shall be expressed in the default user space coordinate system. The page’s bounding box is the smallest rectangle enclosing all of its contents. (If any side of the bounding box lies outside the page’s crop box, the corresponding side of the crop box shall be used instead; see 14.11.2, “Page Boundaries,” for further discussion of the crop box.)

No page object can be specified for a destination associated with a remote go-to action (see 12.6.4.3, “Remote Go-To Actions”) because the destination page is in a different PDF document. In this case, the page parameter specifies an integer page number within the remote document instead of a page object in the current document.

Table 151 – Destination syntax
Syntax Meaning
[ page /XYZ left top zoom ] Display the page designated by page, with the coordinates (left, top) positioned at the upper-left corner of the window and the contents of the page magnified by the factor zoom. A null value for any of the parameters left, top, or zoom specifies that the current value of that parameter shall be retained unchanged. A zoom value of 0 has the same meaning as a null value.
[ page /Fit ] Display the page designated by page, with its contents magnified just enough to fit the entire page within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the page within the window in the other dimension.
[ page /FitH top ] Display the page designated by page, with the vertical coordinate top positioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of the page within the window. A null value for top specifies that the current value of that parameter shall be retained unchanged.
[ page /FitV left ] Display the page designated by page, with the horizontal coordinate left positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of the page within the window. A null value for left specifies that the current value of that parameter shall be retained unchanged.
[ page /FitR left bottom right top ] Display the page designated by page, with its contents magnified just enough to fit the rectangle specified by the coordinates left, bottom, right, and top entirely within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the rectangle within the window in the other dimension.
[ page /FitB ] (PDF 1.1) Display the page designated by page, with its contents magnified just enough to fit its bounding box entirely within the window both horizontally and vertically. If the required horizontal and vertical magnification factors are different, use the smaller of the two, centering the bounding box within the window in the other dimension.
[ page /FitBH top ] (PDF 1.1) Display the page designated by page, with the vertical coordinate top positioned at the top edge of the window and the contents of the page magnified just enough to fit the entire width of its bounding box within the window. A null value for top specifies that the current value of that parameter shall be retained unchanged.
[ page /FitBV left ] (PDF 1.1) Display the page designated by page, with the horizontal coordinate left positioned at the left edge of the window and the contents of the page magnified just enough to fit the entire height of its bounding box within the window. A null value for left specifies that the current value of that parameter shall be retained unchanged.

12.3.2.3 命名目的地

12.3.2.3 Named Destinations

目标位置并非只能通过表 151 中显示的显式语法直接定义,还可以通过名称对象(PDF 1.1)或字节串(PDF 1.2)间接引用。当目标位置位于另一个 PDF 文档中时,这种功能尤为有用。

注 1

链接到另一个文档中第 6 章开头的链接可能会使用名称(如 Chap6.begin)来引用目标位置,而不是使用另一个文档中的具体页码。这样,即使该章节在另一个文档中的位置发生变化,链接也不会失效。如果引用命名目标位置的批注或大纲条目有关联的动作,如远程跳转动作(见12.6.4.3远程跳转动作”)或线索动作(12.6.4.6线索动作”),若动作存在 F 条目,则目标位置在动作的 F 条目所指定的文件中;如果没有 F 条目,则目标位置在当前文件中。

在 PDF 1.1 中,名称对象与目标位置的对应关系应由文档目录中的 Dests 条目定义(见7.7.2文档目录”)。此条目的值应为一个字典,其中每个键都是目标位置的名称,相应的值要么是使用表 151 中所示语法定义目标位置的数组,要么是一个包含 D 条目的字典,且该 D 条目的值为这样的数组。

注 2

后一种形式允许为目标位置关联额外的属性,并且能够实现作为命名目标位置目标的使用跳转动作(见12.6.4.2跳转动作”)。

在 PDF 1.2 及更高版本中,字符串与目标位置的对应关系也可以通过文档名称字典中的 Dests 条目来定义(见7.7.4名称字典”)。此条目的值应为一个名称树(7.9.6名称树”),它将名称字符串映射到目标位置。(出于显示目的,名称树中的键可视为文本字符串。)名称树中键关联的目标位置值可以是数组,也可以是字典,如前一段所述。

注 3

将字符串用作目标位置名称是 PDF 1.2 的功能。如果需要与早期版本的 PDF 兼容,则只能使用名称对象来引用命名目标位置。支持 PDF 1.2 的文档可以包含这两种类型。不过,如果不考虑向后兼容性,应用程序应在 Dests 名称树中使用字符串表示形式 。

Instead of being defined directly with the explicit syntax shown in Table 151, a destination may be referred to indirectly by means of a name object (PDF 1.1) or a byte string (PDF 1.2). This capability is especially useful when the destination is located in another PDF document.

NOTE 1

A link to the beginning of Chapter 6 in another document might refer to the destination by a name, such as Chap6 . begin, instead of by an explicit page number in the other document. Then, the location of the chapter in the other document could change without invalidating the link. If an annotation or outline item that refers to a named destination has an associated action, such as a remote go-to action (see 12.6.4.3, “Remote Go-To Actions”) or a thread action (12.6.4.6, “Thread Actions”), the destination is in the file specified by the action’s F entry, if any; if there is no F entry, the destination is in the current file.

In PDF 1.1, the correspondence between name objects and destinations shall be defined by the Dests entry in the document catalogue (see 7.7.2, “Document Catalog”). The value of this entry shall be a dictionary in which each key is a destination name and the corresponding value is either an array defining the destination, using the syntax shown in Table 151, or a dictionary with a D entry whose value is such an array.

NOTE 2

The latter form allows additional attributes to be associated with the destination, as well as enabling a go-to action (see 12.6.4.2, “Go-To Actions”) that shall be used as the target of a named destination.

In PDF 1.2 and later, the correspondence between strings and destinations may alternatively be defined by the Dests entry in the document’s name dictionary (see 7.7.4, “Name Dictionary”). The value of this entry shall be a name tree (7.9.6, “Name Trees”) mapping name strings to destinations. (The keys in the name tree may be treated as text strings for display purposes.) The destination value associated with a key in the name tree may be either an array or a dictionary, as described in the preceding paragraph.

NOTE 3

The use of strings as destination names is a PDF 1.2 feature. If compatibility with earlier versions of PDF is required, only name objects may be used to refer to named destinations. A document that supports PDF 1.2 can contain both types. However, if backward compatibility is not a consideration, applications should use the string form of representation in the Dests name tree.

12.3.3 文档大纲

12.3.3 Document Outline

PDF 文档可能包含一个文档大纲,符合标准的阅读器可以在屏幕上显示该大纲,允许用户交互式地从文档的一个部分导航到另一个部分。大纲由一个树形结构的大纲条目(有时称为书签)层次结构组成,这些大纲条目作为可视目录向用户展示文档的结构。用户可以通过用鼠标点击它们来交互式地打开和关闭各个条目。当一个条目被打开时,其在层次结构中的直接子条目应在屏幕上可见;每个子条目又可以单独打开或关闭,从而有选择地显示或隐藏层次结构的进一步部分。当一个条目被关闭时,其在层次结构中的所有后代条目都应隐藏。点击任何可见条目的文本将激活该条目,使符合标准的阅读器跳转到与该条目关联的目标位置或触发相关动作。

文档大纲层次结构的根是一个大纲字典,由文档目录中的 Outlines 条目指定(见7.7.2文档目录”)。表 152 显示了这个字典的内容。层次结构中的每个单独的大纲条目都应由一个大纲条目字典定义(表 153)。层次结构中每个层级的条目形成一个链表,通过它们的 PrevNext 条目相互链接,并通过父条目(对于顶级条目则通过大纲字典)中的 FirstLast 条目进行访问。在屏幕上显示时,给定层级的条目应按其在链表中出现的顺序出现。

表 152 – 大纲字典中的条目
类型
Type 名称 (可选)此字典描述的 PDF 对象的类型;如果存在,对于大纲字典应为 Outlines
First 字典 (如果存在任何打开或关闭的大纲条目,则为必需项;应为间接引用)表示大纲中第一个顶级条目的大纲条目字典。
Last 字典 (如果存在任何打开或关闭的大纲条目,则为必需项;应为间接引用)表示大纲中最后一个顶级条目的大纲条目字典。
Count 整数 (如果文档有任何打开的大纲条目,则为必需项)大纲中所有层级可见大纲条目的总数。该值不能为负数。
如果没有打开的大纲条目,则应省略此条目。

表 153 – 大纲条目字典中的条目
类型
Title 文本字符串 (必需)应在此条目的屏幕上显示的文本。
Parent 字典 (必需;应为间接引用)此条目在大纲层次结构中的父条目。顶级条目的父条目应为大纲字典本身。
Prev 字典 (除每个层级的第一个条目外,所有条目均必需;应为间接引用)此大纲层级中的上一个条目。
Next 字典 (除每个层级的最后一个条目外,所有条目均必需;应为间接引用)此大纲层级中的下一个条目。
First 字典 (如果此条目有任何后代,则为必需项;应为间接引用)此条目在大纲层次结构中的第一个直接子条目。
Last 字典 (如果此条目有任何后代,则为必需项;应为间接引用)此条目在大纲层次结构中的最后一个直接子条目。
Count 整数 (如果此条目有任何后代,则为必需项)如果大纲条目是打开的,Count 是所有层级中可见后代大纲条目数量的总和。可见后代大纲条目的数量通过以下递归过程确定:
  步骤 1. 将 Count 初始化为零。
  步骤 2. 将直接子条目的数量加到 Count 中。在此步骤的重复过程中,仅更新原始大纲条目的 Count
  步骤 3. 对于每个 Count 为正且非零的直接子条目,重复步骤 2 和 3。
如果大纲条目是关闭的,Count 为负数,其绝对值是如果打开此大纲条目将显示的后代数量。
Dest 名称、字节串或数组 (可选;如果存在 A 条目,则不应出现)激活此条目时应显示的目标位置(见12.3.2目标位置”)。
A 字典 (可选;PDF 1.1;如果存在 Dest 条目,则不应出现)激活此条目时应执行的动作(见12.6动作”)。
SE 字典 (可选;PDF 1.3;应为间接引用)此条目所引用的结构元素(见14.7.2结构层次结构”)。
(PDF 1.0)条目也可以指定一个与指定结构元素内容显示页面区域相对应的目标位置 (Dest)。
C 数组 (可选;PDF 1.4)一个包含三个范围在 0.0 到 1.0 之间的数字的数组,表示用于大纲条目文本颜色的 DeviceRGB 颜色空间的分量。默认值:[ 0.0 0.0 0.0 ]。
F 整数 (可选;PDF 1.4)一组标志,用于指定显示大纲条目文本的样式特征(见表 154)。默认值:0。

大纲条目字典的 F 条目(PDF 1.4)的值应为一个整数,该整数被解释为指定显示条目样式的单比特标志。标志字中的位位置从低位到高位编号,最低位编号为 1。表 154 显示了这些标志的含义;整数的所有其他位应为 0。

表 154 – 大纲条目标志
位位置 名称 含义
1 斜体 如果设置为 1,则以斜体显示条目。
2 粗体 如果设置为 1,则以粗体显示条目。

示例

以下示例展示了一个典型的大纲字典和大纲条目字典。有关完整大纲层次结构的示例,请见H.6大纲层次结构示例”。

21 0 obj
    << /Count 6
        /First 22 0 R
        /Last 29 0 R
    >>
endobj

22 0 obj
    << /Title ( 第 1 章 )
        /Parent 21 0 R
        /Next 26 0 R
        /First 23 0 R
        /Last 25 0 R
        /Count 3
        /Dest [ 3 0 R /XYZ 0 792 0 ]
    >>
endobj

A PDF document may contain a document outline that the conforming reader may display on the screen, allowing the user to navigate interactively from one part of the document to another. The outline consists of a tree-structured hierarchy of outline items (sometimes called bookmarks), which serve as a visual table of contents to display the document’s structure to the user. The user may interactively open and close individual items by clicking them with the mouse. When an item is open, its immediate children in the hierarchy shall become visible on the screen; each child may in turn be open or closed, selectively revealing or hiding further parts of the hierarchy. When an item is closed, all of its descendants in the hierarchy shall be hidden. Clicking the text of any visible item activates the item, causing the conforming reader to jump to a destination or trigger an action associated with the item.

The root of a document’s outline hierarchy is an outline dictionary specified by the Outlines entry in the document catalogue (see 7.7.2, “Document Catalog”). Table 152 shows the contents of this dictionary. Each individual outline item within the hierarchy shall be defined by an outline item dictionary (Table 153). The items at each level of the hierarchy form a linked list, chained together through their Prev and Next entries and accessed through the First and Last entries in the parent item (or in the outline dictionary in the case of top level items). When displayed on the screen, the items at a given level shall appear in the order in which they occur in the linked list.

Table 152 – Entries in the outline dictionary
Key Type Value
Type name (Optional) The type of PDF object that this dictionary describes; if present, shall be Outlines for an outline dictionary.
First dictionary (Required if there are any open or closed outline entries; shall be an indirect reference) An outline item dictionary representing the first top- level item in the outline.
Last dictionary (Required if there are any open or closed outline entries; shall be an indirect reference) An outline item dictionary representing the last top-level item in the outline.
Count integer (Required if the document has any open outline entries) Total number of visible outline items at all levels of the outline. The value cannot be negative.
This entry shall be omitted if there are no open outline items.

Table 153 – Entries in an outline item dictionary
Key Type Value
Title text string (Required) The text that shall be displayed on the screen for this item.
Parent dictionary (Required; shall be an indirect reference) The parent of this item in the outline hierarchy. The parent of a top-level item shall be the outline dictionary itself.
Prev dictionary (Required for all but the first item at each level; shall be an indirect reference) The previous item at this outline level.
Next dictionary (Required for all but the last item at each level; shall be an indirect reference) The next item at this outline level.
First dictionary (Required if the item has any descendants; shall be an indirect reference) The first of this item’s immediate children in the outline hierarchy.
Last dictionary (Required if the item has any descendants; shall be an indirect reference) The last of this item’s immediate children in the outline hierarchy.
Count integer (Required if the item has any descendants) If the outline item is open, Count is the sum of the number of visible descendent outline items at all levels. The number of visible descendent outline items shall be determined by the following recursive process:
  Step 1. Initialize Count to zero.
  Step 2. Add to Count the number of immediate children. During repetitions of this step, update only the Count of the original outline item.
  Step 3. For each of those immediate children whose Count is positive and non-zero, repeat steps 2 and 3.
If the outline item is closed, Count is negative and its absolute value is the number of descendants that would be visible if the outline item were opened.
Dest name, byte string, or array (Optional; shall not be present if an A entry is present) The destination that shall be displayed when this item is activated (see 12.3.2, “Destinations”).
A dictionary (Optional; PDF 1.1; shall not be present if a Dest entry is present) The action that shall be performed when this item is activated (see 12.6, “Actions”).
SE dictionary (Optional; PDF 1.3; shall be an indirect reference) The structure element to which the item refers (see 14.7.2, “Structure Hierarchy”).
(PDF 1.0) An item may also specify a destination (Dest) corresponding to an area of a page where the contents of the designated structure element are displayed.
C array (Optional; PDF 1.4) An array of three numbers in the range 0.0 to 1.0, representing the components in the DeviceRGB colour space of the colour that shall be used for the outline entry’s text. Default value: [ 0.0 0.0 0.0 ].
F integer (Optional; PDF 1.4) A set of flags specifying style characteristics for displaying the outline item’s text (see Table 154). Default value: 0.

The value of the outline item dictionary’s F entry (PDF 1.4) shall be an integer interpreted as one-bit flags specifying style characteristics for displaying the item. Bit positions within the flag word are numbered from low-order to high-order bits, with the lowest-order bit numbered 1. Table 154 shows the meanings of the flags; all other bits of the integer shall be 0.

Table 154 – Outline item flags
Bit position Name Meaning
1 Italic If set to 1, display the item in italic.
2 Bold If set to 1, display the item in bold.

EXAMPLE

The following example shows a typical outline dictionary and outline item dictionary. See H.6, “Outline Hierarchy Example” for an example of a complete outline hierarchy.

21 0 obj
   << /Count 6
      /First 22 0 R
      /Last 29 0 R
   >>
endobj

22 0 obj
   << /Title ( Chapter 1 )
      /Parent 21 0 R
      /Next 26 0 R
      /First 23 0 R
      /Last 25 0 R
      /Count 3
      /Dest [ 3 0 R /XYZ 0 792 0 ]
   >>
endobj

12.3.4 缩略图

12.3.4 Thumbnail Images

PDF 文档可能包含以缩略图形式呈现页面内容的缩略图图像。符合标准的阅读器可以在屏幕上显示这些图像,允许用户通过点击其缩略图图像导航到相应页面:

Note

缩略图图像不是必需的,并且可以对某些页面包含缩略图图像,而对其他页面则不包含。

页面的缩略图图像应由页面对象中的 Thumb 条目指定的图像 XObject(见7.7.3页面树”)。它具有图像字典([8.9.5]“图像字典”)的通常结构,但只有 WidthHeightColorSpaceBitsPerComponentDecode 条目是重要的;如果存在,表 89 中列出的所有其他条目都将被忽略。(如果指定了 Subtype 条目,其值应为 Image。)图像的颜色空间应为 DeviceGrayDeviceRGB,或者是基于这些颜色空间之一的 Indexed 空间。

Info

此示例展示了一个典型的缩略图图像定义。

12 0 obj
   << /Width 76
      /Height 99
      /ColorSpace /DeviceRGB
      /BitsPerComponent 8
      /Length 13 0 R
      /Filter [ /ASCII85Decode /DCTDecode ]
   >>

stream
s4IA>!"M;*Ddm8XA,lT0!!3,S!/(=R!<E3%!<N<(!WrK*!WrN,
… Omitted data …
endstream
endobj

13 0 obj                % Length of stream
…
endobj

A PDF document may contain thumbnail images representing the contents of its pages in miniature form. A conforming reader may display these images on the screen, allowing the user to navigate to a page by clicking its thumbnail image:

Note

Thumbnail images are not required, and may be included for some pages and not for others.

The thumbnail image for a page shall be an image XObject specified by the Thumb entry in the page object (see 7.7.3, “Page Tree”). It has the usual structure for an image dictionary ([8.9.5], “Image Dictionaries”), but only the Width, Height, ColorSpace, BitsPerComponent, and Decode entries are significant; all of the other entries listed in Table 89 shall be ignored if present. (If a Subtype entry is specified, its value shall be Image.) The image’s colour space shall be either DeviceGray or DeviceRGB, or an Indexed space based on one of these.

EXAMPLE

This example shows a typical thumbnail image definition.

12 0 obj
   << /Width 76
      /Height 99
      /ColorSpace /DeviceRGB
      /BitsPerComponent 8
      /Length 13 0 R
      /Filter [ /ASCII85Decode /DCTDecode ]
   >>

stream
s4IA>!"M;*Ddm8XA,lT0!!3,S!/(=R!<E3%!<N<(!WrK*!WrN,
… Omitted data …
endstream
endobj

13 0 obj                % Length of stream
…
endobj

12.3.5 收藏

12.3.5 Collections

从 PDF 1.7 开始,PDF 文档可以指定符合标准的阅读器的用户界面如何呈现结构或内容相关的文件附件集合。这种呈现方式称为便携式集合。

注 1

便携式集合的目的是呈现、排序和搜索嵌入在包含 PDF 文档中的相关文档集合,例如电子邮件存档、照片集和工程投标文件集。并不要求集合中的文档具有隐含关系甚至相似性;然而,显示相关文档的区分特征有助于文档导航。

集合字典指定便携式集合的查看和组织特性。如果 PDF 文档中存在此字典,符合标准的阅读器应将该文档作为便携式集合呈现。EmbeddedFiles 名称树指定文件附件(见7.11.4嵌入文件流”)。

当符合标准的阅读器首次打开包含集合的 PDF 文档时,它应显示初始文档的内容以及 EmbeddedFiles 名称树中存在的文档列表。文档列表应包括集合模式指定的附加文档信息。初始文档可以是容器 PDF 或其中一个嵌入文档。

注 2

初始文档中的页面内容应包含帮助用户了解集合中包含哪些内容的信息,例如标题和引言段落。

组成集合的文件附件应位于 EmbeddedFiles 名称树中。该树中的所有附件都在集合中;不在该树中的附件则不在集合中。

表 155 – 集合字典中的条目
类型
Type 名称 (可选)此字典描述的 PDF 对象的类型;如果存在,对于集合字典应为 Collection。
Schema 字典 (可选)集合模式字典(见表 156)。如果不存在,符合标准的阅读器可以选择已知存在于文件规范字典中的有用默认值,例如文件名、文件大小和修改日期。
D 字节串 (可选)一个字符串,用于标识 EmbeddedFiles 名称树中的一个条目,该条目决定初始时在用户界面中呈现的文档。如果 D 条目缺失或错误,初始文档应为包含集合字典的那个文档。
View 名称 (可选)初始视图。以下值有效:
D   集合视图应以详细模式呈现,模式字典中的所有信息以多列格式显示。此模式向用户提供最多的信息。
T   集合视图应以平铺模式呈现,集合中的每个文件由一个小图标和模式字典中的一部分信息表示。此模式向用户提供有关文件附件的顶级信息。
H   集合视图应初始隐藏,符合标准的阅读器应提供某种显式操作方式,以便用户查看集合。
默认值:D
Sort 字典 (可选)集合排序字典,指定集合中的项目在用户界面中的排序顺序(见表 158)。

集合模式字典由数量可变的单个集合字段字典组成。每个集合字段字典都有一个由符合标准的编写者选择的键,该键用于将字段与文件规范中的数据相关联。表 156 描述了集合模式字典中的条目。

表 156 – 集合模式字典中的条目
类型
Type 名称 (可选)此字典描述的 PDF 对象的类型;如果存在,对于集合模式字典应为 CollectionSchema。
其他键 字典 (可选)集合字段字典。每个键名由符合标准的编写者自行决定。键名用于标识从文件规范字典的 CI 条目(见表 44中的 CI 键)引用的相应集合项字典。

集合字段字典描述便携式集合中特定字段的属性,包括字段中存储的数据类型以及在文件规范字典中查找字段数据所用的查找键。表 157 描述了集合字段字典中的条目。

表 157 – 集合字段字典中的条目
类型
Type 名称 (可选)此字典描述的 PDF 对象的类型;如果存在,对于集合字段字典应为 CollectionField。
Subtype 名称 (必需)此字典描述的集合字段或文件相关字段的子类型。此条目标识字段中应存储的数据类型。
以下值标识集合项或集合子项字典中的字段类型:
S   文本字段。字段数据应以 PDF 文本字符串的形式存储。
D   日期字段。字段数据应以 PDF 日期字符串的形式存储。
N   数字字段。字段数据应以 PDF 数字的形式存储。
以下值标识文件相关字段的类型:
F   字段数据应为嵌入文件流的文件名,由文件规范的 UF 条目(如果存在)标识;否则由文件规范的 F 条目标识(见表 44)。
Desc   字段数据应为嵌入文件流的描述,由文件规范字典中的 Desc 条目标识(见表 44)。
ModDate   字段数据应为嵌入文件流的修改日期,由嵌入文件参数字典中的 ModDate 条目标识(见表 46)。 CreationDate   字段数据应为嵌入文件流的创建日期,由嵌入文件参数字典中的 CreationDate 条目标识(见表 46)。
Size   字段数据应为嵌入文件的大小,由嵌入文件参数字典中的 Size 条目标识(见表 46)。
N 文本字符串 (必需)符合标准的阅读器应向用户展示的文本字段名称。
O 整数 (可选)字段名称在用户界面中的相对顺序。符合标准的阅读器应按升序对字段进行排序。
V 布尔值 (可选)字段在用户界面中的初始可见性。默认值:true
E 布尔值 (可选)一个标志,指示符合标准的阅读器是否应提供对编辑字段值的支持。默认值:false

集合排序字典标识用于对集合中的项目进行排序的字段。排序类型取决于数据的类型:

  • 如果指定了升序,文本字符串应按字典序从小到大排列。

注 3

字典序排序是符合标准的阅读器的实现依赖项。

  • 如果指定了升序,数字应按数值从小到大排列。
  • 如果指定了升序,日期应按从最早到最新的顺序排列。

表 158 描述了集合排序字典中的条目。

表 158 – 集合排序字典中的条目
类型
Type 名称 (可选)此字典描述的 PDF 对象的类型;如果存在,对于集合排序字典应为 CollectionSort。
S 名称或数组 (必需)符合标准的阅读器用于对集合中的项目进行排序的字段名称或名称列表。如果值是名称,则标识父集合字典中描述的字段。
如果值是数组,则数组的每个元素应是标识父集合字典中描述的字段的名称。使用数组形式是为了允许额外的字段参与排序,其中每个额外字段用于打破平局。更具体地说,如果多个集合项字典在数组中第一个命名的字段上有相同的值,则使用数组中后续命名的字段的值进行排序,直到确定唯一顺序或用尽命名的字段。
A 布尔值或数组 (可选)如果值是布尔值,则指定符合标准的阅读器应按升序(true)还是降序(false)对集合中的项目进行排序。如果值是数组,则数组的每个元素应是布尔值,指定 S 数组中相同索引处的条目应按升序还是降序排序。
如果 A 数组中的条目数多于 S 数组中的条目数,则忽略 A 数组中的多余条目。如果 A 数组中的条目数少于 S 数组中的条目数,则假定 A 数组中缺失的条目为 true
默认值:true

EXAMPLE 1

此示例显示了一个表示电子邮件收件箱的集合字典,其中集合中的每个项目都是一封电子邮件。实际的电子邮件包含在文件规范字典中。与每封电子邮件相关的组织数据在集合架构字典中描述。大多数实际组织数据(发件人、收件人、日期和主题)在集合项目字典中提供,但大小数据来自嵌入式文件参数字典。

/Collection <<
  /Type /Collection
    /Schema <<
    /Type /CollectionSchema
    /from << /Subtype /S /N (From) /O 1 /V true /E false>>
    /to << /Subtype /S /N (To) /O 2 /V true /E false >>
    /date << /Subtype /D /N (Date received) /O 3 /V true /E false >>
    /subject << /Subtype /S /N (Subject) /O 4 /V true /E false >>
    /size << /Subtype /Size /N (Size) /O 5 /V true /E false >>
    >>
  /D (Doc1)
  /View /D
  /Sort << /S /date /A false >>
>>

EXAMPLE 2

此示例显示了一个集合项字典和一个集合子项字典。这些字典包含与 12.4.2,“页面标签”中示例中指定的架构条目相对应的条目。7.11.6,“集合项”指定集合项和集合子项字典。

/CI <<
    /Type /CollectionItem
    /from (Rob McAfee)
    /to (Patty McAfee)
    /subject <<
        /Type /CollectionSubitem
        /P (Re:)
        /D (Let's have lunch on Friday!)
    >>
    /date (D:20050621094703-07’00’)
>>

Beginning with PDF 1.7, PDF documents may specify how a conforming reader’s user interface presents collections of file attachments, where the attachments are related in structure or content. Such a presentation is called a portable collection.

NOTE 1

The intent of portable collections is to present, sort, and search collections of related documents embedded in the containing PDF document, such as email archives, photo collections, and engineering bid sets. There is no requirement that documents in a collection have an implicit relationship or even a similarity; however, showing differentiating characteristics of related documents can be helpful for document navigation.

A collection dictionary specifies the viewing and organizational characteristics of portable collections. If this dictionary is present in a PDF document, the conforming reader shall present the document as a portable collection. The EmbeddedFiles name tree specifies file attachments (see 7.11.4, “Embedded File Streams”).

When a conforming reader first opens a PDF document containing a collection, it shall display the contents of the initial document, along with a list of the documents present in the EmbeddedFiles name tree. The document list shall include the additional document information specified by the collection schema. The initial document may be the container PDF or one of the embedded documents.

NOTE 2

The page content in the initial document should contain information that helps the user understand what is contained in the collection, such as a title and an introductory paragraph.

The file attachments comprising a collection shall be located in the EmbeddedFiles name tree. All attachments in that tree are in the collection; any attachments not in that tree are not.

Table 155 describes the entries in a collection dictionary.

Table 155 – Entries in a collection dictionary
Key Type Value
Type name (Optional) The type of PDF object that this dictionary describes; if present, shall be Collection for a collection dictionary.
Schema dictionary (Optional) A collection schema dictionary (see Table 156). If absent, the conforming reader may choose useful defaults that are known to exist in a file specification dictionary, such as the file name, file size, and modified date.
D byte string (Optional) A string that identifies an entry in the EmbeddedFiles name tree, determining the document that shall be initially presented in the user interface. If the D entry is missing or in error, the initial document shall be the one that contains the collection dictionary.
View name (Optional) The initial view. The following values are valid:
D   The collection view shall be presented in details mode, with all information in the Schema dictionary presented in a multi-column format. This mode provides the most information to the user.
T   The collection view shall be presented in tile mode, with each file in the collection denoted by a small icon and a subset of information from the Schema dictionary. This mode provides top-level information about the file attachments to the user.
H   The collection view shall be initially hidden, The conforming reader shall provide means for the user to view the collection by some explicit action.
Default value: D
Sort dictionary (Optional) A collection sort dictionary, which specifies the order in which items in the collection shall be sorted in the user interface (see Table 158).

A collection schema dictionary consists of a variable number of individual collection field dictionaries. Each collection field dictionary has a key chosen by the conforming writer, which shall be used to associate a field with data in a file specification. Table 156 describes the entries in a collection schema dictionary.

Table 156 – Entries in a collection schema dictionary
Key Type Value
Type name (Optional) The type of PDF object that this dictionary describes; if present, shall be CollectionSchema for a collection schema dictionary.
Other keys dictionary (Optional) A collection field dictionary. Each key name is chosen at the discretion of the conforming writer. The key name shall be used to identify a corresponding collection item dictionary referenced from the file specification dictionary's CI entry (see CI key in Table 44).

A collection field dictionary describes the attributes of a particular field in a portable collection, including the type of data stored in the field and the lookup key used to locate the field data in the file specification dictionary. Table 157 describes the entries in a collection field dictionary.

Table 157 – Entries in a collection field dictionary
Key Type Value
Type name (Optional) The type of PDF object that this dictionary describes; if present, shall be CollectionField for a collection field dictionary.
Subtype name (Required) The subtype of collection field or file-related field that this dictionary describes. This entry identifies the type of data that shall be stored in the field.
The following values identify the types of fields in the collection item or collection subitem dictionary:
S   A text field. The field data shall be stored as a PDF text string.
D   A date field. The field data shall be stored as a PDF date string.
N   A number field. The field data shall be stored as a PDF number.
The following values identify the types of file-related fields:
F   The field data shall be the file name of the embedded file stream, as identified by the UF entry of the file specification, if present; otherwise by the F entry of the file specification (see Table 44).
Desc   The field data shall be the description of the embedded file stream, as identified by the Desc entry in the file specification dictionary (see Table 44).
ModDate   The field data shall be the modification date of the embedded file stream, as identified by the ModDate entry in the embedded file parameter dictionary (see Table 46). CreationDate   The field data shall be the creation date of the embedded file stream, as identified by the CreationDate entry in the embedded file parameter dictionary (see Table 46).
Size   The field data shall be the size of the embedded file, as identified by the Size entry in the embedded file parameter dictionary (see Table 46).
N text string (Required) The textual field name that shall be presented to the user by the conforming reader.
O integer (Optional) The relative order of the field name in the user interface. Fields shall be sorted by the conforming reader in ascending order.
V boolean (Optional) The initial visibility of the field in the user interface. Default value: true.
E boolean (Optional) A flag indicating whether the conforming reader should provide support for editing the field value. Default value: false.

A collection sort dictionary identifies the fields that shall be used to sort items in the collection. The type of sorting depends on the type of data:

  • Text strings shall be ordered lexically from smaller to larger, if ascending order is specified.

NOTE 3

Lexical ordering is an implementation dependency for conforming readers.

  • Numbers shall be ordered numerically from smaller to larger, if ascending order is specified.
  • Dates shall be ordered from oldest to newest, if ascending order is specified.

Table 158 describes the entries in a collection sort dictionary.

Table 158 – Entries in a collection sort dictionary
Key Type Value
Type name (Optional) The type of PDF object that this dictionary describes; if present, shall be CollectionSort for a collection sort dictionary.
S name or array (Required) The name or names of fields that the conforming reader shall use to sort the items in the collection. If the value is a name, it identifies a field described in the parent collection dictionary.
If the value is an array, each element of the array shall be a name that identifies a field described in the parent collection dictionary. The array form shall be used to allow additional fields to contribute to the sort, where each additional field shall be used to break ties. More specifically, if multiple collection item dictionaries have the same value for the first field named in the array, the values for successive fields named in the array shall be used for sorting, until a unique order is determined or until the named fields are exhausted.
A boolean or array (Optional) If the value is a boolean, it specifies whether the conforming reader shall sort the items in the collection in ascending order (true) or descending order (false). If the value is an array, each element of the array shall be a boolean value that specifies whether the entry at the same index in the S array shall be sorted in ascending or descending order.
If the number of entries in the A array is larger than the number of entries in the S array the extra entries in the A array shall be ignored. If the number of entries in the A array is less than the number of entries in the S array the missing entries in the A array shall be assumed to be true.
Default value: true.

EXAMPLE 1

This example shows a collection dictionary representing an email in-box, where each item in the collection is an email message. The actual email messages are contained in file specification dictionaries. The organizational data associated with each email is described in a collection schema dictionary. Most actual organizational data (from, to, date, and subject) is provided in a collection item dictionary, but the size data comes from the embedded file parameter dictionary.

/Collection <<
  /Type /Collection
    /Schema <<
    /Type /CollectionSchema
    /from << /Subtype /S /N (From) /O 1 /V true /E false>>
    /to << /Subtype /S /N (To) /O 2 /V true /E false >>
    /date << /Subtype /D /N (Date received) /O 3 /V true /E false >>
    /subject << /Subtype /S /N (Subject) /O 4 /V true /E false >>
    /size << /Subtype /Size /N (Size) /O 5 /V true /E false >>
    >>
  /D (Doc1)
  /View /D
  /Sort << /S /date /A false >>
>>

EXAMPLE 2

This example shows a collection item dictionary and a collection subitem dictionary. These dictionaries contain entries that correspond to the schema entries specified in the Example in 12.4.2, “Page Labels.”. 7.11.6, “Collection Items” specifies the collection item and collection subitem dictionaries.

/CI <<
    /Type /CollectionItem
    /from (Rob McAfee)
    /to (Patty McAfee)
    /subject <<
        /Type /CollectionSubitem
        /P (Re:)
        /D (Let's have lunch on Friday!)
    >>
    /date (D:20050621094703-07’00’)
>>