zoukankan      html  css  js  c++  java
  • pdf reference 格式具体说明

    1. PDF概要

    1.1. 图像模型

    PDF能以平台无关、高效率的方式描叙复杂的文字、图形、排版。

    PDF 用图像模型来实现设备无关。

    图像模型同意应用程序以抽象对象描叙文字、图像、图标。而不是通过详细的像素点。

    把描写叙述抽象对象的语言称作“页描写叙述语言”。

    PDF文档中存储都是以“页描写叙述语言”表示的各种抽象对象。

    要把PDF文档输出到详细设备上,产生详细像素点,须要有个翻译软件,把抽象对象渲染到详细输出设备上,称这个“翻译软件”为“规则扫描”软件。

    1.2. 属性

    PDF 具有设备无关、可压缩、安全、增量改动、可扩展等特性。

    2. 语法

    2.1. 字符集

    PDF是大写和小写敏感的语言的。及Aa是不一样的。

    PDF字符集分文三种:

    1).空白字符

      空白字符包含Null(NUL)Tab(HT)Line Feed(LF)Form Feed(FF)Carriage return(CR)Space(SP)。除了在commentstringstreams中,全部的空白符都是一样的。PDF把多个连续的空白符看作一个。

    2).切割字符

    分隔字符包含(, ), <, >, [, ], {, }, /, and %

    切割字符是用来分开需实体对象的,包含stringcommentarraysnames

    3).常规字符

    除了上面的两种字符之外的字符都称作常规字符。

    2.2. 凝视(comment

    凝视没有语义。仅仅是凝视说明作用。凝视以%开头。到本行结尾。比如

    abc% comment {/%) blah blah blah

    123

     “comment {/%) blah blah blah”为凝视。

    2.3. 对象

    3.3.1 Boolean 对象

    Boolean 对象仅仅有truefalse两种值,能够用在arraydictionary中。truefalse是keyword。

    3.3.2 Numeric 对象

    Numeric对象是数组对象。它的取值范围和详细的机器有关,详细范围能够參考“《PDF referenceappendix C”。

    Numeric 对象分为IntegerReal对象。

    Integer对象就是证书对象。能够在数字前面加+/-的符号。标识正负。比如。

    123 43445 +17 98 0

    Real对象是实数对象。

    须要注意的是PDFReal对象是定点小数。而不是浮点小数。不支持像“6.02E23”这种标识。正确标识比如:

    34.5 3.62 +123.6 4. .002 0.0

    假设Integer对象超出的标识范围。会自己主动转化为Real对象。可是假设Real对象超出标识范围。会报错。

    全部能够用Real对象的地方都能够用Integer对象,Integer对象会自己主动转换为Real对象。所以对于须要Real对象1.0的地方。直接写1就能够,不用写成1.0

    3.3.3 String 对象

    String对象是一个字节数列的集合。字节的取值范围为0~255。字符串的长度范围跟详细平台有关,详细參考“《PDF referenceappendix C”。

    String对象分为Literal stringHexadecimal string

    Literal string对象是是用()括起来的一些字符,除了不正确称的括号(如“(”或者“)”)或者反斜杠(“/”)外的字符,都能够出如今Literal string中。

    比如:

    (This is a string)

    (Strings may contain newlines

    and such.)

    (Strings may contain balanced parentheses ( ) and

    special characters (*!&}^% and so on).)

    (The following is an empty string.)

    ()

    (It has zero (0) length.)

    Literal String 能够使用转意字符。如表1

    TABLE 3.2 Escape sequences in literal strings

    SEQUENCE

    MEANING

    Line feed (LF)

    Carriage return (CR)

    Horizontal tab (HT)

    

    Backspace (BS)

    f

    Form feed (FF)

    (

    Left parenthesis

    )

    Right parenthesis

    \

    Backslash

    ddd

    Character code ddd (octal)

    所以不在表1中的转义字符会被忽略。

    假设一个字符串太长。放在一行不在方便,能够分开写在多行,然后用反斜杠连接起来。例如以下。

    (These

    two strings

    are the same.)

    (These two strings are the same.)

    假设不加反斜杠,就会相当在末尾加了一个 。例如以下

    (These

    two strings

    are the same.)

     

    (These

    two strings

    are the same.)

    ddd 标识是一个八进制数,提供一种标识不可显示的ASCII的方式。

    (This string contains 245two octal characters307.)

    ddd 仅仅需“” 后后面三位数。包含0。比如

    053是表示053

    而不是53或者53

    Hexadecimal string 是用尖括号<>括起来的0-9A-Fa-f)的字符。如

    <4E6F762073686D6F7A206B6120706F702E>

    每一对表示一个字节。假设字符是奇数,在字符最后字符补零,组成一对。比如:

    <901FA3> 标识的901FA3

    假设是<901FA>会是901FA0

    3.3.4 Name objects

    Name对象一串原子、唯一的字符,用来标识一个对象。原子性是说Name对象没有内部结构了。唯一性是说假设两个Name是一样的,说明它们标识的师动一个对象。

    Name对象以“/”开头。后面紧跟对象名。“/”和第一个字符之间不能有空格。“/”并非Name对象的一部分,仅仅是用来说明“/”后面的字符是Name对象。比如:

    /Name1

    /ASomewhatLongerName

    /A;Name_WithVarious***Characters?

    /1.2

    /$$

    /@pattern

    /.notdef

    Name对象通常是由“常规字符”组成,不能是“空白字符”和“切割字符”。

    可是在PDF1.2中,能够包含“空白字符”和“分隔字符”,可是必须以“#”开头。紧跟对应字符的两位十六进制编码。比如表2

    #20代表的一个字符,而不是三个字符。比如/A#20B是四个字符,而不是六个。

    Literal Name

    Result T

    /Adobe#20Green

    Adobe Green

    /PANTONE#205757#20CV

    PANTONE 5757 CV

    /paired#28#29parentheses

    paired()parentheses

    /The_Key_of_F#23_Minor

    The_Key_of_F#_Minor

    /A#42

    AB

    3.3.5 Array 对象

    Array对象是一个一维对象集合。集合能够包括String对象、Name对象等不论什么其它对象。

    假设要组成多维数组,可通过Array对象中包括Array对象的方式。

    Array对象的标识方式:

    [549 3.14 false (Ralph) /SomeName]

    3.3.6 Dictionary 对象

    Dictionary对象是键值对的集合,用来描写叙述复杂对象。键必须是name对象,值能够是不论什么对象,包含Dictionary对象。

    Dictionary对象是用“<< >>”括起来的表示。比如:

    << /Type /Example

    /Subtype /DictionaryExample

    /Version 0.01

    /IntegerItem 12

    /StringItem (a string)

    /Subdictionary << /Item1 0.4

    /Item2 true

    /LastItem (not!)

    /VeryLastItem (OK)

    >>

    >>

    每一个Dictionary 对象代表一个复杂对象,每一个键值对表示对象的一个属性。

    依照惯例。每一个Dictionary都会有一个Type键值对。用来标识这个Dictionary描写叙述的对象的类别。

    一般还会有个SubType键值对,用来标识Dictionary标识对象子类别。比如一个字体的DictionaryType键的值是FontsubType键的值是Type1, TrueType,或者别的字形名称。

    3.3.7 Stream 对象

    Stream对象和String对象一样也是一个字节序列,可是不一样的地方。Stream对象能够被PDF应用程序递增的读取,而不是像String对象要整个读入内存。Stream对象能够不限长度的。而String对象是长度后受平台最大字符长度的限制。

    Stream对象包含一个Dictionary对象和

    treamendstreamkeyword,以及streamendstream中见包括的一行或者多行字节。格式例如以下:

    dictionary

    stream

    Zero or more lines of bytes

    Endstream

    Stream对象必须包括在Indirect对象中。而且Dictionary对象不是Indirect对象。

    keywordstream必须以“ ”或者“ ”结尾。不能以“ ”结尾。组成Stream对象的字节位于keywordstreamendstream中间。

    Dictionary对象一个属相用来说明字节的长度。在PDF1.2中,组成Stream对象的字节也能够来自文件。在Stream对象的Dictionary对象中指定文件的路径。在这样的情况下,keywordstreamendstream中间的字节是被忽略的。

    在表3中列出了。Stream对象中的Dictionary对象常有一些属性。

    KEY

    TYPE

    VALUE

    Length

    integer

    (Required) The number of bytes from the beginning of the line following

    the keyword stream to the last byte just before the keyword

    endstream. (There may be an additional EOL marker, preceding

    endstream, that is not included in the count and is not logically part

    of the stream data.) See Stream Extent,above, for further discussion.

    Filter

    name or array

    (Optional) The name of a filter to be applied in processing the stream

    data found between the keywords stream and endstream, or an array

    of such names. Multiple filters should be specified in the order in

    which they are to be applied.

    DecodeParms

    dictionary or array

    (Optional) A parameter dictionary, or an array of such dictionaries,

    used by the filters specified by Filter. If there is only one filter and that

    filter has parameters, DecodeParms must be set to the filters parameter

    dictionary unless all the filters parameters have their default

    values, in which case the DecodeParms entry may be omitted. If there

    are multiple filters and any of the filters has parameters set to nondefault

    values, DecodeParms must be an array with one entry for

    each filter: either the parameter dictionary for that filter, or the null

    object if that filter has no parameters (or if all of its parameters have

    their default values). If none of the filters have parameters, or if all

    their parameters have default values, the DecodeParms entry may be

    omitted. (See implementation note 7 in Appendix H.)

    F

    file specification

    (Optional; PDF 1.2) The file containing the stream data. If this entry

    is present, the bytes between stream and endstream are ignored, the

    filters are specified by FFilter rather than Filter, and the filter parameters

    are specified by FDecodeParms rather than DecodeParms. However,

    the Length entry should still specify the number of those bytes.

    (Usually there are no bytes and Length is 0.)

    FFilter

    name or array

    (Optional; PDF 1.2) The name of a filter to be applied in processing

    the data found in the streams external file, or an array of such names.

    The same rules apply as for Filter.

    FDecodeParms

    dictionary or array

    (Optional; PDF 1.2) A parameter dictionary, or an array of such dictionaries,

    used by the filters specified by FFilter. The same rules apply

    as for DecodeParms.

    3.3.8 Null 对象

    Null对象不等于不论什么对象。用keywordnull代表。

    Indirect对象引用不存在对象等价与引用空对象。

    3.3.9 Indirect 对象

    不论什么的对象都能够声明为Indirect对象,Indirect对象用一个Object Identifier标识这个对象。以便其它对象能够通过Object Identifier引用它。

    Object Indirect有两部分组成:

    1).Object Number 由一个正数表示。一般PDF中的Object Number是连续的。但不是必须的,他能够是随意顺序。

    2).Generation Number由一个非负数标识。

    在一个新建立的PDF文档中。Generation Number0。当文档被更新或者改动以后。Generation Number会被改动为非零值。

    除了Object Identifier ,Inderect 对象还包括keywordobjendobj以及他们中间包括的对象。

    比如:

    12 0 obj

    (Brillig)

    Endobj

    12 Object Number0Generation NumberIndirect对象值为(Brillig)

    这个对象能够被引用通过Object Indirect 和keywordR。比如:

    12 0 R

    假设引用一个未定义的Indirect对象。并不报错,而是等价于引用了一个Null对象(值为null)。

    样例Example 3.1 定义了一个Indirect对象。它的Object Identifier7 0

    它长度有引用了一个Object Identifier8 0Indirect对象。

    Example 3.1

    7 0 obj

    << /Length 8 0 R >> % An indirect reference to object 8

    stream

    BT

    /F1 12 Tf

    72 712 Td

    (A stream with an indirect length) Tj

    ET

    endstream

    Endobj

    2.4. 过滤器(Filter

    Filter Stream对象中引入的。能够通过Stream对象中的Dictionary对象的

    Filter键表示(假设字节通过文件引入,是FFilter键),有一写Filter须要一些參数能够通过DecodeParms(假设字节通过文件引入,是FDecodeParams

    /Filter [/ASCII85Decode /LZWDecode]

    在创建PDF过程中,应用程序用对PDf中的数据做了压缩或或者转码,等到有应用程序读取PDF的时候。在用相应的Filter对数据进行解码,然后输出到显示设备,进行显示。

    假设存在多个Filter,这些Filter会组成一个管道,即第一个Filter输出,会作为第二个Filter的输入。第二个Filter的输出回作为第三个Filter的输入。一次类推。

    Filter的种类大概分为两类:

    ASCII Filter用来解码恢复已经倍编码为ASCII文本的数据。

    Decompression filters 用来解压那些被压缩的数据。

    关于详细的Filter的种类和解码方式等细节參考《PDF reference3.3.1-3.3.7节中介绍。

    2.5. 文档结构

    档结构如图1

    PDF的文

    Header仅仅有一行。用来表示文件遵循的PDF协议版本。

    Body 中存放的是组成文件的全部的Objects

    Cross-reference table 中存放的是关于Indirect对象的信息。

    Trailer 中指明了Cross-reference table的位置和在Body中特别指定的对象的位置。

    Incremental Updates 是在Trailer后面加入的对象。

    假设一个文件被改动了,在文件的末尾还会包括添加的对象。

    文件里一行的结尾符能够是‘ ’、‘ ’、‘ ’。除了在Stream对象中的字节,一般一行不超过255个字节。

    3.5.1 Header

    PDF文档开头会包括此文件所遵循的PDF协议版本号。格式例如以下:

    %PDF-1.4

    查看PDF文档的软件,如Adobe ReaderAdobe Acrobat等等。都能向后兼容。

    比方软件是按1.4版本号实现,对于遵循版本号1.4之前的版本号。比方1.31.2,都能够查看。

    对于文档遵循版本号比软件遵循版本号高的情况,软件会忽略那些它不认识的新特性。

    3.5.2 Body

    PDF文档的Body是有好多代表文档内容的Indirect对象组成。

    这些对象代表文字、图像、表格等组成PDF文档的Objects

    3.5.3 Cross-reference table

    一个PDF能够包括一个或者多个Cross-reference sections,一般PDF文档创建的时候。Cross-reference table 就由一个Cross-reference section组成。假设是Linearized PDF(线性PDF用于网络浏览PDF格式,详细能够參见《PDF referenceAppendix F)会有两个。假设此PDF加入新的对象,就会加入新的Cross-reference section

    每一个Cross-reference section,以keywordxref独占一行开头。

    后边跟着一个或者多个Cross-reference subsection

    每个Cross-reference subsection 第一行是两个以空格切割的数字开头,第一个数字代表此Cross-reference subsection包括的起始ObjectObject Identifier。第二个数字代表这个Cross-reference subsection包括的Object的个数。所以这个特性决定,每一个Cross-reference subsection 中的Object编号都是连续的。

    比方,第一行是

    28 5

    标识此Cross-reference subsection 包括Object Number28325Object

    在第一行之后包括一个或者多个Entries(条目),每一个Entry独占一行,一共占20个字节,有两种格式,一种是代表Entry正在使用称作Used Entry。第三个字段使用关键词n表示,还有一种代表Entry不在使用。代表Free Entry,第三个字段用f表示。Used Entry的格式为:

    nnnnnnnnnn ggggg n eol

    nnnnnnnnnn 10个字节代表对象在文档中的偏移量(offset)。假设偏移量不够10前面补零。

    ggggg 5个字节代表对象Generation,作用后边做进一步解释。假设数字不够五位。也是前面补零凑齐。

    n 一个字节代表这个对象还是使用。

    eol 两个字节标识行结束(end of line)。

    能够是‘ ’、‘ ’、‘ ,假设是‘ ’、‘ ,在前面不一个空格组成两个字节。

     每一个字段用一个空格切割。总共加一起是20个字符。

    Free Entry的格式为:

    nnnnnnnnnn ggggg f eol

    nnnnnnnnnn 是一个10字节的数字,标识的是下一个Free EntryObject identifier。这样全部 Free Entry能够组成一个链表。

    ggggg 是一个5字节的数字,标识Generation。作用后面解释。

    f 是一个字节,代表这是一个Free Entry

    eol 是两个字节行结束符。

    Free Entry的第一个字段表示下一个Free EntryObject Number,这样全部的Free Entry都能够组成一个链表结构。假设是链表就须要有个链表头。所以规定Cross-reference subsection第一个EntryFree Entry,它的第一个字段是0,第二个字段Generation65536,作为Free Entry链表头。链表最后一个Free Entry的第一个字段设置为0。指向第一个Object

    除了第一个EntryPDF文档中全部的Generation初始值都是0

    假设Indirect Object 被删除了,对应的Used Entry改动为Free Entry,这个EntryGeneration被加一。

    所以当一个Entry被又一次使用。这个Entry都会有一个新的Generation

    Generation的最大值为65536。当达到最大值以后,这个Entry就不能在又一次使用了。

    Example 3.5

    xref

    0 6

    0000000003 65535 f

    0000000017 00000 n

    0000000081 00000 n

    0000000000 00007 f

    0000000331 00000 n

    0000000409 00000 n

    Example 3.5 显示了一个Cross-reference section。这个Cross-reference section由一个Cross-reference subsection 组成。Cross-reference subsection有六个Entries组成。

    当中有四个Used EntryObject Number各自是1245

    还有两个free EntryObject Number各自是03

    Object Number 3的对象已经被删除了,所以Object Number 0Free Entry 的第一个字段是3。而Object Number3Free Entry的第一个字段为0。指向第一个Entry

    这样Free Entry就是连起来了。

    Example 3.6

    xref

    0 1

    0000000000 65535 f

    3 1

    0000025325 00000 n

    23 2

    0000025518 00002 n

    0000025635 00000 n

    30 1

    0000025777 00000 n

    Example 3.5 显示了一个Cross-reference section,这个Cross-reference section4Cross-reference subsection 组成。

    3.5.4 File Trailer

    一个Trailer同意PDF应用程序高速的查找Cross-reference section和一些特定的ObjectTrailer的格式是:

    trailer

    << key1 value1

    key2 value2

    keyn valuen

    >>

    startxref

    Byte_offset_of_last_cross-reference_section

    %%EOF

    一个Trailerkeyword后面跟着一个Dictionary对象。然后跟着startxrefkeyword占一行,然后跟着一个offset(指的从文件开头到最后一个Cross-reference section的偏移量),最后跟着Trailer的一行结束标志%%EOF

    4显示Trailer中的Dictionary对象的成员。

    Key

    Type

    Value

    Size

    Integer

    (Required) The total number of entries in the files cross-reference table, as defined

    by the combination of the original section and all update sections. Equivalently, this

    value is 1 greater than the highest object number used in the file.

    Prev

    Integer

    (Present only if the file has more than one cross-reference section) The byte offset from

    the beginning of the file to the beginning of the previous cross-reference section.

    Root

    Dictionary

    (Required; must be an indirect reference) The catalog dictionary for the PDF document

    contained in the file (see Section 3.6.1, Document Catalog).

    Encrypt

    Dictionary

    (Required if document is encrypted; PDF 1.1) The documents encryption dictionary

    (see Section 3.5, Encryption).

    Info

    Dictionary

    (Optional; must be an indirect reference) The documents information dictionary

    (see Section 9.2.1, Document Information Dictionary).

    ID

    Array

    (Optional; PDF 1.1) An array of two strings constituting a file identifier (see Section

    9.3, File Identifiers) for the file.

    Example 3.7

    trailer

    << /Size 22

    /Root 2 0 R

    /Info 1 0 R

    /ID [ <81b14aafa313db63dbd6f981e49f94f4>

    <81b14aafa313db63dbd6f981e49f94f4>]

    >>

    startxref

    18799

    %%EOF

    3.5.5 增量更新(Incremental Updates

    增量更新同意PDF文件的改动能够不用改动整个文件。仅仅是把改变、添加的对象加入到文件末尾。长处例如以下:

    1).提高对大文件的小的改动的速度。

    2).降低数据丢失的风险。

    3).提高HTTP connection改动文件的效率。

    4).对于一些已经签名(signed)文件,是不可能改动原来的数据,由于仅仅要改动原来的数据,之前的签名就无效了。

    增量更新一个PDF文件的时候。添加、改动的对象会被加入到文件末尾,形成一个Update Body,然后包括添加、改动和删除队形的Cross-reference section会被加入到Update Body的后面。最后会包括的一个新的Trail,它的offset会指导新加入的Cross-reference section,他的Dictionary对象中的Prev属性值之处之前Cross-reference section的位置。

    这样就和之前文档结构关联起来了。

    经过多次增量更新之后,一个PDF文件格式就可能如图。

    2.6. 加密(encryption


    PDF能够通过加密保护文档内容。阻止未授权的訪问。PDF至加密String对象和Stream对象。不会加密Number对象和Boolean对象等标识文档结构,而不是文档内容的对象。

    PDF的机密信息,用Trailer中的Dictionary对象中的Encrypt属性标识,Encrypt属性也是个Dictionary对象,称这个DictionaryEncryption Dictionary。下表显示Encryption Dictionary的属性。

    Key

    Type

    Value

    Filter

    Name

    (Required) The name of the security handler for this document; see below. Default value:

    Standard, for the built-in security handler. (Names for other security handlers can be

    registered using the procedure described in Appendix E.)

    V

    Number

    (Optional but strongly recommended) A code specifying the algorithm to be used in encrypting

    and decrypting the document:

    0 An algorithm that is undocumented and no longer supported, and whose use is

    strongly discouraged.

    1 Algorithm 3.1 on page 73, with an encryption key length of 40 bits; see below.

    2 (PDF 1.4) Algorithm 3.1 on page 73, but allowing encryption key lengths greater

    than 40 bits.

    3 (PDF 1.4) An unpublished algorithm allowing encryption key lengths ranging

    from 40 to 128 bits. (This algorithm is unpublished as an export requirement of

    the U.S. Department of Commerce.)

    The default value if this entry is omitted is 0, but a value of 1 or greater is strongly recommended.

    (See implementation note 15 in Appendix H.)

    Length

    Number

    (Optional; PDF 1.4; only if V is 2 or 3) The length of the encryption key, in bits. The value

    must be a multiple of 8, in the range 40 to 128. Default value: 40.

    R

    Number

    (Required) A number specifying which revision of the standard security handler should

    be used to interpret this dictionary. The revision number should be 2 if the document is

    encrypted with a V value less than 2 (see Table 3.13) and does not have any of the access

    permissions set (via the P entry, below) that are designated Revision 3in Table 3.15;

    otherwise (that is, if the document is encrypted with a V value greater than 2 or has any

    Revision 3access permissions set), this value should be 3.

    O

    String

    (Required) A 32-byte string, based on both the owner and user passwords, that is used in

    computing the encryption key and in determining whether a valid owner password was

    entered. For more information, see Encryption Key Algorithmon page 78 andPassword

    Algorithmson page 79.

    U

    String

    (Required) A 32-byte string, based on the user password, that is used in determining

    whether to prompt the user for a password and, if so, whether a valid user or owner password

    was entered. For more information, see Password Algorithmson page 79.

    P

    Integer

    (Required) A set of flags specifying which operations are permitted when the document is

    opened with user access (see Table 3.15).

    不像其它对象中的String对象,Encryption Dictionary中的String对象不能用常规的加密方法,进行加密。Encryption Dictionary中的Filter属性指定Security Handler负责对其加密。默认的情况Filter的值为Standard。

    3.6.1 标准加密算法(General Encryption Algorithm

    PDF通用加密使用MD5作为hash函数。选用RC4作为加密算法。RC4是对称加密算法,他的密钥能够通过各种方式计算出来。下节讨论生成密钥的方面。先看一下加密的过程。

    1).取得要加密对象的Object Identifier(包含Object NumberObject Generation组成)。对于不是Indirect String对象,取包涵它的Indirect对象的Object Identifier

    2).n字节的key,加上由Object Number的后三位加上Object Generation后两位组成的5位。组成n+5个字节。然后用这(n+5)个字节作为hash函数的输入參数。

    3).使用hash输出结果的(n+5)个字节,最多不超过16个字节,作为key。调用RC4。对要加密数据进行加密。

    构建PDF文档时候,对于Stream对象是先加密。然后在用编码Filter进行编码。查看PDF文档时候,是用Filter进行解码。然后在解密。

    对于String对象先进行escape-sequence processing and hexadecimal decoding

    。然后在进行解密。

    3.6.2 密钥的生成

    PDF的加解密过程是通过两个password进行的:Owner PasswordUser Password

    PDF 生成是的时候是更具是否用户提供password和一些权限限制,假设是就是对文档进行加密。

    PDF读取软件,读取PDF的时候,假设是加密文档,会要求用户输入两个password中的随意一个。假设输入的是Owner Password。那么用户就有文档权限,除了改动文档和password的权限。

    权限通过Encryption Dictionary中的P属性值进行指定。P值是一个32为的Number对象,当中bit代表不同的权限。

    在不同的版本号(Reversion)中,P每一个bit代表的权限值,是不一样。详细值能够參考《PDF Reference》中第77页。

    版本号是通过Encryption Dictionary 中的R属性值指定,能够是2或者3

    Encryption Dictionary中的O属性值是Owner Password通过一定加密过程生成值。而U属性是User Password通过一定加密过程生成的。对于R=2R=3的情况。O属性值和U属性值的生成过程是不一样。

    详细能够參考《PDF Reference79页。

    上文提到的RC4加密之后用到的密钥,也是通过Owner PasswordUser Password 依照一定方法生成的详细过程能够參考《PDF Reference78页。

    2.7. 文档结构

    PDF文档能够被看成一个有PDF Body部分的对象组成的一个TreeTree的根就是Catalog Dictionary(文件夹结构)。而Catalog Dictionary结构中有包括非常多属性。比方Page Tree包括了全部组成文档Page的对象。

    下图能够标识PDF文档的层级结构。

    3.7.1文件夹结构(document catalog

    Key

    Type

    Value

    Type

    Name

    (Required) The type of PDF object that this dictionary describes; must

    be Catalog for the catalog dictionary.

    Version

    Name

    (Optional; PDF 1.4) The version of the PDF specification to which the

    document conforms (for example, 1.4), if later than the version specified

    in the files header (see Section 3.4.1,File Header). If the header specifies

    a later version, or if this entry is absent, the document conforms to

    the version specified in the header. This entry enables a PDF producer

    application to update the version using an incremental update; see Section

    3.4.5, Incremental Updates.(See implementation note 18 in Appendix

    H.)

    Note: The value of this entry is a name object, not a number, and so must

    be preceded by a slash character (/) when written in the PDF file (for example,

    /1.4).

    Pages

    Dictionary

    (Required; must be an indirect reference) The page tree node that is the

    root of the documents page tree (see Section 3.6.2,Page Tree).

    Pagelabels

    NumberTree

    (Optional; PDF 1.3) A number tree (see Section 3.8.5, Number Trees)

    defining the page labeling for the document. The keys in this tree are

    page indices; the corresponding values are page label dictionaries (see

    Section 8.3.1, Page Labels). Each page index denotes the first page in a

    labeling range to which the specified page label dictionary applies. The

    tree must include a value for page index 0.

    Names

    Dictionary

    (Optional; PDF 1.2) The documents name dictionary (see Section 3.6.3,

    Name Dictionary).

    Dests

    Dictionary

    (Optional; PDF 1.1; must be an indirect reference) A dictionary of names

    and corresponding destinations (see Named Destinationson page

    476).

    ViewerPreferences

    Dictionary

    (Optional; PDF 1.2) A viewer preferences dictionary (see Section 8.1,

    Viewer Preferences) specifying the way the document is to be displayed

    on the screen. If this entry is absent, viewer applications should

    use their own current user preference settings.

    PageLayout

    Name

    (Optional) A name object specifying the page layout to be used when the

    document is opened:

    SinglePage Display one page at a time.

    OneColumn Display the pages in one column.

    TwoColumnLeft Display the pages in two columns, with oddnumbered

    pages on the left.

    TwoColumnRight Display the pages in two columns, with oddnumbered

    pages on the right.

    (See implementation note 19 in Appendix H.) Default value: SinglePage.

    PageMode

    Name

    (Optional) A name object specifying how the document should be displayed

    when opened:

    UseNone Neither document outline nor thumbnail images

    visible

    UseOutlines Document outline visible

    UseThumbs Thumbnail images visible

    FullScreen Full-screen mode, with no menu bar, window

    controls, or any other window visible

    Default value: UseNone.

    Outlines

    Dictionary

    (Optional) A name object specifying how the document should be displayed

    when opened:

    UseNone Neither document outline nor thumbnail images

    visible

    UseOutlines Document outline visible

    UseThumbs Thumbnail images visible

    FullScreen Full-screen mode, with no menu bar, window

    controls, or any other window visible

    Default value: UseNone.

    Threads

    Array

    (Optional; must be an indirect reference) The outline dictionary that is the

    root of the documents outline hierarchy (see Section 8.2.2,Document

    Outline).

    OpenAction

    Array or dictionary

    (Optional; PDF 1.1) A value specifying a destination to be displayed or

     an action to be performed when the document is opened. The value is

    either an array defining a destination (see Section 8.2.1, Destinations)

    or an action dictionary representing an action (Section 8.5, Actions). If

    this entry is absent, the document should be opened to the top of the

    first page at the default magnification factor.

    AA

    Dictionary

    (Optional; PDF 1.4) An additional-actions dictionary defining the actions

    to be taken in response to various trigger events affecting the document

    as a whole (see Trigger Eventson page 514). (See also implementation

    note 20 in Appendix H.)

    URI

    Dictionary

    (Optional) A URI dictionary containing document-level information for

    URI (uniform resource identifier) actions (see URI Actionson page

    .

    AcroForm

    Dictionary

    (Optional; PDF 1.2) The documents interactive form (AcroForm) dictionary

    (see Section 8.6.1, Interactive Form Dictionary).

    523)

    Metadata

    Stream

    (Optional; PDF 1.4; must be an indirect reference) A metadata stream

    containing metadata for the document (see Section 9.2.2, Metadata

    Streams).

    StructTreeBoot

    Dictionary

    (Optional; PDF 1.3) The documents structure tree root dictionary (see

    Section 9.6.1, Structure Hierarchy).

    MarkInfo

    Dictionary

    (Optional; PDF 1.4) A mark information dictionary containing information

    about the documents usage of Tagged PDF conventions (see Section

    9.7.1, Mark Information Dictionary).

    Lang

    Text String

    (Optional; PDF 1.4) A language identifier specifying the natural language

    for all text in the document except where overridden by language specifications

    for structure elements or marked content (see Section 9.8.1,

    Natural Language Specification). If this entry is absent, the language is

    considered unknown.

    SpiderInfo

    Dictionary

    (Optional; PDF 1.3) A Web Capture information dictionary containing

    state information used by the Acrobat Web Capture (AcroSpider) plugin

    extension (see Section 9.9.1, Web Capture Information Dictionary).

    OutputIntents

    Array

    (Optional; PDF 1.4) An array of output intent dictionaries describing the

    color characteristics of output devices on which the document might be

    rendered (see Output Intentson page 684).

    3.7.2 页面树(Page Tree

    组成PDF文档的全部页都通过Tree结构进行组织。称作Page TreeTree结构能够同意读取PDF内容的应用程序,在有限的内存上,读取非常大文档。

    组成Page Tree有两种类型的节点:一种是节点他自己也是一个page tree,称作page tree node。还有一种节点叶子节点,称作page objects

    为了进一步优化性能,好多创建PDF文件的软件,把page tree组成一个平衡数(balanced tree)。

    3.7.2.1 page tree nodes

    KEY

    TYPE

    VALUE

    Type

    Name

    (Required) The type of PDF object that this dictionary describes; must be Pages for

    a page tree node.

    Parent

    Dictionary

    (Required except in root node; must be an indirect reference) The page tree node that

    is the immediate parent of this one.

    Kids

    Array

    (Required) An array of indirect references to the immediate children of this node.

    The children may be page objects or other page tree nodes.

    Count

    Integer

    (Required) The number of leaf nodes (page objects) that are descendants of this

    node within the page tree.

    Example 3.9

    2 0 obj

    << /Type /Pages

    /Kids [ 4 0 R

    10 0 R

    24 0 R

    ]

    /Count 3

    >>

    endobj

    4 0 obj

    << /Type /Page

    Additional entries describing the attributes of this page

    >>

    endobj

    10 0 obj

    << /Type /Page

    Additional entries describing the attributes of this page

    >>

    endobj

    24 0 obj

    << /Type /Page

    Additional entries describing the attributes of this page

    >>

    Endobj

    Example 3.9 展示了一个文档有三个页,对于每一个页的内容。详细查看下一节的介绍。

    3.7.2.2 Page Objects

    Page Objects Page Tree的叶子节点。包括了文档中一个页的全部属性。下标列出Page Object的全部属性。在表中属性,标有(inheritable)的条目。是说明其值能够从他的父对象中继承(详细能够參考下一节)。

    关于表中rectangledate对象3.9小节进行介绍。

    KEY

    TYPE

    VALUE

    Type

    Name

    (Required) The type of PDF object that this dictionary describes; must be

    Page for a page object.

    Parent

    Dictionary

    (Required; must be an indirect reference) The page tree node that is the immediate

    parent of this page object.

    LastModified

    Date

    (Required if PieceInfo is present; optional otherwise; PDF 1.3) The date and

    time (see Section 3.8.2, Dates) when the pages contents were most recently

    modified. If a page-piece dictionary (PieceInfo) is present, the

    modification date is used to ascertain which of the application data dictionaries

    that it contains correspond to the current content of the page

    (see Section 9.4, Page-Piece Dictionaries).

    Resources

    Dictionary

    (Required; inheritable) A dictionary containing any resources required by

    the page (see Section 3.7.2, Resource Dictionaries). If the page requires

    no resources, the value of this entry should be an empty dictionary; omitting

    the entry entirely indicates that the resources are to be inherited from

    an ancestor node in the page tree.

    MediaBox

    Rectangle

    (Required; inheritable) A rectangle (see Section 3.8.3, Rectangles), expressed

    in default user space units, defining the boundaries of the physical

    medium on which the page is intended to be displayed or printed (see

    Section 9.10.1, Page Boundaries).

    CropBox

    Rectangle

    (Optional; inheritable) A rectangle, expressed in default user space units,

    defining the visible region of default user space. When the page is displayed

    or printed, its contents are to be clipped (cropped) to this rectangle

    and then imposed on the output medium in some implementationdefined

    manner (see Section 9.10.1, Page Boundaries). Default value:

    the value of MediaBox.

    BleedBox

    Rectangle

    (Optional; PDF 1.3) A rectangle, expressed in default user space units, defining

    the region to which the contents of the page should be clipped

    when output in a production environment (see Section 9.10.1, Page

    Boundaries). Default value: the value of CropBox.

    TrimBox

    Rectangle

    (Optional; PDF 1.3) A rectangle, expressed in default user space units, defining

    the intended dimensions of the finished page after trimming (see

    Section 9.10.1, Page Boundaries). Default value: the value of CropBox.

    ArtBox

    Rectangle

    (Optional; PDF 1.3) A rectangle, expressed in default user space units, defining

    the extent of the pages meaningful content (including potential

    white space) as intended by the pages creator (see Section 9.10.1,Page

    Boundaries). Default value: the value of CropBox.

    BoxColorInfo

    Dictionary

    (Optional) A box color information dictionary specifying the colors and

    other visual characteristics to be used in displaying guidelines on the

    screen for the various page boundaries (see Display of Page Boundaries

    on page 679). If this entry is absent, the viewer application should use its

    own current default settings.

    Contents

    Stream or array

    (Optional) A content stream (see Section 3.7.1, Content Streams) describing

    the contents of this page. If this entry is absent, the page is empty.

    The value may be either a single stream or an array of streams. If it is an

    array, the effect is as if all of the streams in the array were concatenated, in

    order, to form a single stream. This allows a program generating a PDF

    file to create image objects and other resources as they occur, even though

    they interrupt the content stream. The division between streams may

    occur only at the boundaries between lexical tokens (see Section 3.1, Lexical

    Conventions), but is unrelated to the pages logical content or organization.

    Applications that consume or produce PDF files are not required

    to preserve the existing structure of the Contents array. (See implementation

    note 22 in Appendix H.)

    Rotate

    Integer

    (Optional; inheritable) The number of degrees by which the page should

    be rotated clockwise when displayed or printed. The value must be a multiple

    of 90. Default value: 0.

    Group

    dictionary

    (Optional; PDF 1.4) A group attributes dictionary specifying the attributes

    of the pages page group for use in the transparent imaging model (see

    Sections 7.3.6, Page Group,and 7.5.5,Transparency Group XObjects).

    Thumb

    Stream

    (Optional) A stream object defining the pages thumbnail image (see Section

    8.2.3, Thumbnail Images).

    B

    array

    (Optional; PDF 1.1; recommended if the page contains article beads) An array

    of indirect references to article beads appearing on the page (see Section

    8.3.2, Articles; see also implementation note 23 in Appendix H).

    The beads are listed in the array in natural reading order.

    Dur

    Number

    (Optional; PDF 1.1) The pages display duration (also called its advance

    timing): the maximum length of time, in seconds, that the page will be

    displayed during presentations before the viewer application automatically

    advances to the next page (see Section 8.3.3, Presentations). By

    default, the viewer does not advance automatically.

    Trans

    Dictionary

    (Optional; PDF 1.1) A transition dictionary describing the transition effect

    to be used when displaying the page during presentations (see Section

    8.3.3, Presentations).

    Annots

    Array

    (Optional) An array of annotation dictionaries representing annotations

    associated with the page (see Section 8.4, Annotations).

    AA

    Dictionary

    (Optional; PDF 1.2) An additional-actions dictionary defining actions to

    be performed when the page is opened or closed (see Section 8.5.2, Trigger

    Events; see also implementation note 24 in Appendix H).

    Metadata

    Stream

    (Optional; PDF 1.4) A metadata stream containing metadata for the page

    (see Section 9.2.2, Metadata Streams).

    PieceInfo

    Dictionary

    (Optional; PDF 1.3) A page-piece dictionary associated with the page (see

    Section 9.4, Page-Piece Dictionaries).

    StructParents

    Integer

    (Required if the page contains structural content items; PDF 1.3) The integer

    key of the pages entry in the structural parent tree (seeFinding Structure

    Elements from Content Itemson page 600).

    ID

    String

    (Optional; PDF 1.3; indirect reference preferred) The digital identifier of the

    pages parent Web Capture content set (see Section 9.9.5,Object Attributes

    Related to Web Capture).

    PZ

    Number

    (Optional; PDF 1.3) The pages preferred zoom (magnification) factor: the

    factor by which it should be scaled to achieve the naturaldisplay magnification

    (see Section 9.9.5, Object Attributes Related to Web Capture).

    SeperationInfo

    Dictionary

    (Optional; PDF 1.3) A separation dictionary containing information needed

    to generate color separations for the page (see Section 9.10.3, Separation

    Dictionaries).

    Example 3.10 显示文档中一个Page,这个Page由一个thumb。两个Annotation

    MediaBox指定这个Page将要一个信纸大小的纸上。Resources指定这个Page使用了三种字体,各自是是F3F5F7.

    Example 3.10

    3 0 obj

    << /Type /Page

    /Parent 4 0 R

    /MediaBox [0 0 612 792]

    /Resources << /Font << /F3 7 0 R

    /F5 9 0 R

    /F7 11 0 R

    >>

    /ProcSet [/PDF]

    >>

    /Contents 12 0 R

    /Thumb 14 0 R

    /Annots [ 23 0 R

    24 0 R

    ]

    >>

    endobj

    3.7.2.3 页属性的继承(Inheritance of Page Attributes

    上表能够看到有些页的属性值被指定为inheritableinheritable说明page object的属性值假设被省略了,它的值能够从他的父对象page tree object中继承。

    假设这个属性在page object中是required。那么父对象中,一定要提供这个值。假设这个属性是optional的,那么使用父对象的中的属性值或者取默认值。

    3.7.3.4 名字对比表(Name Dictionary

    PDF文档,有些对象是通过Name直接引用的,而不是通过Indirect ObjectName和相应的对象之间的关系是通过Name Dictionary表建立,Name Dictionary能够通过Trailer中文件文件夹中的Names属性值找到。

    3.8 Content Streams and Resources

    3.8.1 Content Stream

    Content Stream 是一个Stream对象。其数据部分是一个指令(instruction)队列,用来描写叙述一个页是怎么被显示的。每个页可能由多个Content Stream组成,这样的情况全部的Content Stream组成一个指令队列,相当于一个大的Content Stream

    Content Stream 中的之类,在被解释运行之前,先要用指定的Filtercontent Stream的内容进行解码。

    每个指令由operand (操作数)和operator(操作码)组成。Operand位于Operator前面

    Operands能够由随意的PDF基本对象组成,除了Stream对象。有一些特殊的Operators须要Dictionary作为他的OperandsIndirect对象不同意做Operands

    Operators PDF文档中的keyword。它和Name对象的差别是,不以‘/’开头。

    4569章进步说明PDF支持的Operators

    通常情况下,假设一个PDF读取软件的时候遇到不认识的Operators,会报错。假设不想让其报错。能够用BXEXkeyword包括那些指令。这样PDF读取软件会忽略不认识的Operators

    3.8.2 Resources Dictionary

    有的时候,Operator须要引用自身Content Stream之外的Indirect对象,比如字体、一个包括图片的Stream对象。这样的情况就须要须要把引用到的Indirect对象声明为Named ResourceResources Dictionary中定义各种Named Resource

    Resource Dictionary 通过三种方式和Content Stream关联在一起:

    1).Content Stream 是页内容的Contents属性的值,这样的情况。相应的Resource Dictionary是页内容的Resources的属性的值。

    2).对于除了页内容外的其它Content Stream,相应的Resource Dictionary是通过Stream中的Dictionary对象的Resource属性的值指定的。

    3).对于XObjectType 3 font会忽略Content Stream中的Resource属性。这样的情况,Resource是使用包括XobjectType 3 font的页的Resource的值。

     

    每个Resource DictionaryKey值是资源类型的名字。Key相应Value也是一个Dictionary对象,我们称作SubDictionary

    SubDictionary对象的Key值指定类型的一个资源名称。SubDictionary对象Value值是引用的资源对象。

    下表列出了全部的资源类型名称。

    ExtGState

    Dictionary

    (Optional) A dictionary mapping resource names to graphics state parameter

    dictionaries (see Section 4.3.4, Graphics State Parameter Dictionaries).

    ColorSpace

    Dictionary

    (Optional) A dictionary mapping each resource name to either the name of a

    device-dependent color space or an array describing a color space (see Section

    4.5, Color Spaces).

    Pattern

    Dictionary

    (Optional) A dictionary mapping resource names to pattern objects (see Section

    4.6, Patterns).

    Shading

    Dictionary

    (Optional; PDF 1.3) A dictionary mapping resource names to shading dictionaries

    (see Shading Dictionarieson page 233).

    XObject

    Stream

    (Optional) A dictionary mapping resource names to external objects (see Section

    4.7, External Objects).

     

    Font

    Dictionary

    (Optional) A dictionary mapping resource names to font dictionaries (see

    Chapter 5).

    ProSet

    Array

    (Optional) An array of predefined procedure set names (see Section 9.1,

    Procedure Sets).

    Properties

    Dictionary

    (Optional; PDF 1.2) A dictionary mapping resource names to property list

    dictionaries for marked content (see Section 9.5.1, Property Lists).

     

    Example 3.11

    << /ProcSet [/PDF /ImageB]

    /Font << /F5 6 0 R

    /F6 8 0 R

    /F7 10 0 R

    /F8 12 0 R

    >>

    /XObject << /Im1 13 0 R

    /Im2 15 0 R

    >>

    >>

    Example 定一个包括 FontProcSetXObject类型资源的Resource Dictionary

    Font资源包括四个对象各自是F5F6F7F8

    3.9 Common Data Structures

    这节介绍四种数据对象Text StringDateRectanglesName TreesNumber Trees。这五种数据类型,不能用在Content Stream对象中。

    3.9.1 Text Strings

    Text Strings 对象是PDFDocEncoding或者Unicode编码。

    PDFDocEncodingISO Latin 1编码的一个超集。

    假设用Unicode编码,Text Strings前两个字节必须是254256,代表Text StringUnicode编码。

    不论什么使用Unicode编码的地方。都会有一个转义字符串来表名字符串使用哪国语言写的。转移字符串有下列部分顺序组成。

    1. The Unicode value U+001B (that is, the byte sequence 0 followed by 27)

    2. A 2-character ISO 639 language codefor example, en for English or ja for

    Japanese

    3. (Optional) A 2-character ISO 3166 country codefor example, US for the

    United States or JP for Japan

    4. The Unicode value U+001B

    3.9.2 Dates

    PDF文档的日期格式是:

    (D:YYYYMMDDHHmmSSOHH'mm')

    l YYYY代表年

    l MM代表月

    l DD代表月

    l HH代表小时

    l mm代表分

    l SS代表秒

    l O表示是本地时间和标准国际标准时间(UT time)的关系。O假设是‘+’标识本地时间比国际标准时间慢。O假设是‘-’标识本地时间比国际标准时间快,详细的差值由O后面的HHmm标识。

    l HH表示本地时间和国际标准时间查多少个小时。

    l mm’ 表示本地时间和国际标准时间查多少个分钟。

    mm后面的单引號是语法的一部分。不能省略。

    YYYY后面全部的项都是能够省略的,MMDD的默认值是01,其它项的默认值是00

    For example, December 23, 1998, at 7:52 PM, U.S. Pacific Standard Time, is represented

    by the string

    D:19981223195208'00'

    3.9.3 Rectangles

    Rectangles 是一个Array对象。通过两个对角坐标来描写叙述矩形位置,通常格式是:

    [llx lly urx ury]

    llx lly 表示左下角(lower-left)的坐标xy

    urx ury 标识右上角(up-right)的坐标xy

    也能够通过左上交和右下角坐标确定一个矩形。

    3.9.4 Name Trees

    Name Trees 由几种节点组成,每一个节点都是一个Dictionary对象。

    Name Trees有三种类型的节点,Root节点、Kids节点、Name节点(相当于叶子节点)。

    Root节点中包括对Kids节点或者Name节点的引用,可是不能同一时候两种都存在。

    Kids节点中包括对Name节点应用。

    这样由这三种节点就能够组成一颗逻辑上的数。

    Name Trees 各种节点Dictionary中有三种属性。

    Key

    Type

    Value

    Kids

    Array

    (Root and intermediate nodes only; required in intermediate nodes; present in the root node

    if and only if Names is not present) An array of indirect references to the immediate children

    of this node. The children may be intermediate or leaf nodes.

    Names

    array

    (Root and leaf nodes only; required in leaf nodes; present in the root node if and only if Kids

    is not present) An array of the form

    [key1 value1 key2 value2 keyn valuen]

    where each keyi is a string and the corresponding valuei is an indirect reference to the

    object associated with that key. The keys are sorted in lexical order, as described below.

    Limits

    Array

    (Intermediate and leaf nodes only; required) An array of two strings, specifying the (lexically)

    least and greatest keys included in the Names array of a leaf node or in the Names

    arrays of any leaf nodes that are descendants of an intermediate node.

    The

    Name属性的的KeyString对象,并且Key是按字母顺序排序的。

    Limit对象是一个由两个String对象组成。标识Limit属性所在节点(包含它的子节点)中,最小和最大的Name属性的Key值。

    Example 3.24Name Trees结构描写叙述例如以下图分类的元素周期表。

    1 0 obj

    /Kids [ 2 0 R % Root node

    3 0 R

    4 0 R

    ]

    >>

    endobj

    2 0 obj

    << /Limits [(Actinium) (Gold)] % Intermediate node

    /Kids [ 5 0 R

    6 0 R

    7 0 R

    8 0 R

    9 0 R

    10 0 R

    11 0 R

    ]

    >>

    endobj

    3 0 obj

    << /Limits [(Hafnium) (Protactinium)] % Intermediate node

    /Kids [ 12 0 R

    13 0 R

    14 0 R

    15 0 R

    16 0 R

    17 0 R

    18 0 R

    19 0 R

    ]

    >>

    endobj

    40 obj

    << /Limits [(Radium) (Zirconium)] % Intermediate node

    /Kids [ 20 0 R

    21 0 R

    22 0 R

    23 0 R

    24 0 R

    ]

    >>

    endobj

    5 0 obj

    << /Limits [(Actinium) (Astatine)] % Leaf node

    /Names [ (Actinium) 25 0 R

    (Aluminum) 26 0 R

    (Americium) 27 0 R

    (Antimony) 28 0 R

    (Argon) 29 0 R

    (Arsenic) 30 0 R

    (Astatine) 31 0 R

    ]

    >>

    endobj

    24 0 obj

    << /Limits [(Xenon) (Zirconium)] % Leaf node

    /Names [ (Xenon) 129 0 R

    (Ytterbium) 130 0 R

    (Yttrium) 131 0 R

    (Zinc) 132 0 R

    (Zirconium) 133 0 R

    ]

    >>

    endobj

    25 0 obj

    89 % Atomic number (Actinium)

    endobj

    133 0 obj

    40 % Atomic number (Zirconium)

    Endobj

     

    3.9.5 Number Trees

    Number Trees Name Trees结构相似,差别在于Number Trees节点Name属性中的Key值是Integer对象。而不是String对象。

    3.9 Functions(函数)对象

    尽管PDF不是一个编程语言。可是提供了一些函数对象,用于数学、採样还原等等计算。全部的函数对象都会有一些通用的属性例如以下表:

    Key

    Type

    Value

    FunctionType

    Integer

    (Required) The function type:

    0 Sampled function

    2 Exponential interpolation function

    3 Stitching function

    4 PostScript calculator function

    Domain

    Array

    (Required) An array of 2 × m numbers, where m is the number of input

    values. For each i from 0 to m 1, Domain2i must be less than or equal to

    Domain2i+1, and the ith input value, xi , must lie in the interval

    Domain2i xiDomain2i+1. Input values outside the declared domain are

    clipped to the nearest boundary value.

    Range

    array

    (Required for type 0 and type 4 functions, optional otherwise; see below) An

    array of 2 × n numbers, where n is the number of output values. For each j

    from 0 to n 1, Range2j must be less than or equal to Range2j+1, and the jth

    output value, yj , must lie in the interval Range2j yj Range2j+1. Output

    values outside the declared range are clipped to the nearest boundary value.

    If this entry is absent, no clipping is done.

    每种类型的函数,还会有特定的函数属性和计算过程。详细能够參考《PDF reference3.9.13.9.4节的介绍。

    3.10 文件引用(File Specifications

    我们能够通过文件引用(File Specifications)。在PDF文档中已用别的文件里的内容。

    文件引用分文简单文件引用(simple file specification)和全文件引用(full file specification)。简单文件引用能够是String对象也能够是Dictionary对象。全文件引用仅仅能是Dictionary对象。

    文件引用是平台无关的。当在详细平台上读取PDF文档的时候,会转换为平台相关的文件引用。

    3.10.1 文件引用字符串(File Specification Strings

    文件引用字符串通过多个子字符串组成。每一个部分用‘/’进行切割。假设‘/’是子字符串的一部分,就须要转义,在前面加两个反斜杠“\”。

    (in\/out) 代表的是(in/out

    文件引用还能够分文相对文件引用和绝对文件引用,其含义和相对路劲和绝对路径差点儿相同。以‘/’开头的是绝对文件引用,否则为相对文件引用。

    PDF1.2以后的协议中。同意组成文件引用的子字符串能够是多字节字符,比方中文。这样的必需要有String对象的十六进制的表示方法。因为‘/(ASCII码为0x2f)和‘’(ASCII码为0x5c)。但多自己字符中包括2f5c的时候,要在前面加入一个5c,比方有个两个字节的编码为<89 5C>,要写成<89 5C 5C>

    3.10.2 文件引用字典(File Specification Strings

    文件引用字典是个Dictionary对象。它同意多个文件相应多个不同的文件系统。

    下边是Dictionary对象包括的属性:

    Key

    Type

    Value

    Type

    Name

    required)值为FileSpec指明这是个文件引用对象。

    FS

    Name

    optional)文件系统的文成。PDF仅仅有一个标准文件系统URL

    F

    String

    Required if DosMacUnix entries are all absent)文件描写叙述字符串。

    DosMacUnix属性都没有的时候使用。

    Dos

    String

    optional)指定Dos系统中使用的文件引用。

    Mac

    String

    optional)指定Mac系统中使用的文件引用。

    Unix

    String

    optional)指定Unix系统中使用的文件引用。

    ID

    Array

    optional)文件标识(详细作用參考《PDF reference9.3节)。

    V

    Boolean

    optional PDF1.2)指定引用文件是是否是易变(volatile)。

    假设是TruePDF读取软件不要缓冲引用文件的内容。

    EF

    Dictionary

    嵌入(embedded)引用文件Dictionary对象。

    RF

    Dictionary

    引用文件Dictionary对象。

    參考文章


  • 相关阅读:
    基础数据类型:列表
    基础数据类型(数字、布尔值、字符串)
    深浅copy
    集合
    逻辑运算
    poj 2287 Tian Ji -- The Horse Racing(贪心)
    hdu 1547 Bubble Shooter(深搜)
    hdu 1242 Rescue
    hdu 1175 连连看(深搜)
    hdu 2298 Toxophily(数学题)
  • 原文地址:https://www.cnblogs.com/yutingliuyl/p/7209482.html
Copyright © 2011-2022 走看看