附录 I(规范性)PDF 版本和兼容性¶
Annex I (normative) PDF Versions and Compatibility
I.1 概述¶
I.1 General
PDF 的目标是让人们能够轻松可靠地交换和查看电子文档。理想情况下,这意味着任何符合标准的阅读器都应该能够显示任何 PDF 文件的内容,即使 PDF 文件是在符合标准的阅读器开发之前或之后创建的。实际上,偶尔会引入新版本的 PDF 来提供以前不存在的附加功能。此外,符合标准的阅读器可能支持 PDF 的私有扩展,这使得某些符合标准的阅读器比其他阅读器更强大,具体取决于存在的扩展。
PDF 的设计旨在使用户能够查看符合标准的阅读器理解的文档中的所有内容,并使符合标准的阅读器能够忽略或通知用户不理解的对象。是否忽略或通知用户是根据每个功能做出的决定,由确认阅读器自行决定。
The goal of PDF is to enable people to exchange and view electronic documents easily and reliably. Ideally, this means that any conforming reader should be able to display the contents of any PDF file, even if the PDF file was created long before or long after the conforming reader was developed. In reality, new versions of PDF are occasionally introduced to provide additional capabilities not present before. Furthermore, conforming readers may support private extensions to PDF, making some conforming readers more capable than others, depending on what extensions are present.
PDF has been designed to enable users to view everything in the document that the conforming reader understands and to enable the conforming reader to ignore or inform the user about objects not understood. The decision whether to ignore or inform the user is made on a feature-by-feature basis, at the discretion of the confirming reader.
I.2 PDF 版本号¶
I.2 PDF Version Numbers
PDF 版本号标识 Adobe PDF 规范的特定版本。PDF 文件标有该文件所遵循的 Adobe PDF 规范的版本号。
PDF 版本号采用 M . m 的形式,其中 M 是主版本号,m 是次版本号,每个版本号都以十进制整数表示。
PDF 规范后续版本的版本号通过增加 m 或增加 M 并将 m 设置为零来形成,如下所示:
- 如果 PDF 的更改方式与以前的版本不向上兼容,则增加主版本号。(实际上,这种情况从未发生过;当前主版本为 1。)
- 如果 PDF 的更改方式与以前的版本向上兼容,则增加次版本号。(当前次版本为 7。)
- 如果 PDF 文件中包含本规范中定义的扩展机制之一的私有数据,则 PDF 版本号根本不会改变。
PDF 文件第一行的标头指定 PDF 版本(请参阅 7.5.2“文件标头”)。从 PDF 1.4 开始,PDF 版本也可以在文档目录的版本条目中指定,本质上是通过覆盖文件头中指定的版本来更新与文件关联的版本(请参阅 7.7.2“文档目录”)。如以下段落所述,符合要求的产品在打开或保存文档时的行为取决于将 PDF 文件的版本与符合要求的产品支持的 PDF 版本进行比较。
符合要求的阅读器应尝试读取任何 PDF 文件,即使该文件的版本比符合要求的阅读器的版本更新。
如果符合要求的阅读器打开的 PDF 文件的主版本号比其支持的版本更新,则应警告用户它不太可能成功读取文档,并且用户无法更改或保存文档。在遇到无法识别的功能而导致的第一个错误时,符合要求的阅读器应通知用户发生了错误,但不会报告其他错误。
(尽管如此,某些错误仍应始终报告,包括文件 I/O 错误、内存不足错误和命令失败通知。)如果可能,应继续处理。
如果符合要求的阅读器打开的 PDF 文件的次版本号比其支持的版本新,则应通知用户该文档可能包含符合要求的阅读器不理解的信息。如果符合要求的阅读器遇到错误,则应通知用户 PDF 文件的版本比预期的要新,发生了错误,并且不会再报告其他错误。
在修改和保存文档时,PDF 文件的版本是否应更改以及如何更改取决于几个因素。如果 PDF 文件的版本比符合要求的产品支持的版本新,则符合要求的产品不应更改该版本 - 也就是说,PDF 文件的版本绝不能更改为旧版本。如果 PDF 文件的版本比符合要求的产品支持的版本旧,则符合要求的产品可能会更新 PDF 文件的版本以匹配符合要求的产品的版本。如果用户通过将另一个 PDF 文件的内容插入到文档中来修改文档,则保存的文档的版本应为符合要求的产品版本、原始 PDF 文件的版本和插入的 PDF 文件的版本中的最新版本。
The PDF version number identifies a specific version of the Adobe PDF specification. A PDF file is labelled with the version number of the Adobe PDF specification that the file conforms to.
PDF version numbers take the form M . m, where M is the major and m the minor version number, each represented as a decimal integer.
The version number for a subsequent version of the PDF specification is formed either by incrementing m or by incrementing M and setting m to zero, as follows:
- The major version is incremented if PDF changes in a way that is not upward-compatible from previous versions. (In practice, this has never happened; the current major version is 1.)
- The minor version is incremented if PDF changes in a way that is upward-compatible from previous versions. (The current minor version is 7.)
- The PDF version number does not change at all if private data is included in a PDF file by one of the extension mechanisms defined in this specification.
The header in the first line of a PDF file specifies a PDF version (see 7.5.2, "File Header"). Starting with PDF 1.4, a PDF version can also be specified in the Version entry of the document catalogue, essentially updating the version associated with the file by overriding the one specified in the file header (see 7.7.2, "Document Catalog"). As described in the following paragraphs, the conforming product’s behaviour upon opening or saving a document depends on comparing the PDF file's version with the PDF version that the conforming product supports.
A conforming readers shall attempt to read any PDF file, even if the file’s version is more recent than that of the conforming reader.
If a conforming reader opens a PDF file with a major version number newer than the version that it supports, it should warn the user that it is unlikely to be able to read the document successfully and that the user cannot change or save the document. Upon the first error that is caused by encountering an unrecognized feature, the conforming reader should notify the user that an error has occurred but that no further errors will be reported.
(Some errors should nevertheless be always reported, including file I/O errors, out-of-memory errors, and notifications that a command has failed.) Processing should continue if possible.
If a conforming reader opens a PDF file that has a minor version number newer than the version that it supports, it should notify the user that the document may contain information the conforming reader does not understand. If the conforming reader encounters an error, it should notify the user that the PDF file’s version is newer than expected, an error has occurred, and no further errors will be reported.
Whether and how the version of a PDF file should change when the document is modified and saved depends on several factors. If the PDF file has a newer version than the conforming product supports, the conforming product should not alter the version—that is, a PDF file’s version should never be changed to an older version. If the PDF file has an older version than the conforming product supports, the conforming product may update the PDF file’s version to match the conforming product’s version. If a user modifies a document by inserting the contents of another PDF file into it, the saved document’s version should be the most recent of the conforming product’s version, the original PDF file's version, and the inserted PDF file’s version.
I.3 功能兼容性¶
I.3 Feature Compatibility
当定义新版本的 PDF 时,许多功能只需向现有词典添加新条目即可引入。符合规范的阅读器的早期版本不会注意到这些条目的存在,并且表现得好像它们不存在一样。因此,这些新功能既向前兼容,又向后兼容。同样,向词典对象添加 PDF 规范中未描述的条目不会影响符合规范的阅读器的行为。有关如何选择与未来版本的 PDF 兼容的键名的信息,请参阅附件 E。有关如何在 PDF 文件中指定公共扩展的使用的讨论,请参阅 7.12.2,“开发人员扩展词典”。
在某些情况下,新功能是无法忽略的,因为忽略会妨碍某些重要操作,例如查看或打印页面。例如,如果页面的内容流使用某种新型过滤器进行编码,那么符合要求的阅读器的早期版本就无法查看或打印该页面,即使内容流(如果已解码)可以被阅读器完全理解。在这种情况下,除了给出错误之外别无选择。这些新功能是向前兼容的,但不向后兼容。
在少数情况下,新功能的定义方式会被符合要求的阅读器的早期版本忽略,但输出会以某种方式降级,而不会出现任何错误指示。如果 PDF 文件由符合要求的早期版本编辑,而早期版本不理解该文件使用的某些功能,则这些功能的出现可能会或可能不会保留下来。
When a new version of PDF is defined, many features are introduced simply by adding new entries to existing dictionaries. Earlier versions of conforming readers do not notice the existence of such entries and behave as if they were not there. Such new features are therefore both forward- and backward-compatible. Likewise, adding entries not described in the PDF specification to dictionary objects does not affect the conforming reader’s behaviour. See Annex E for information on how to choose key names that are compatible with future versions of PDF. See 7.12.2, “Developer Extensions Dictionary” for a discussion of how to designate the use of public extensions in PDF file.
In some cases, a new feature is impossible to ignore, because doing so would preclude some vital operation such as viewing or printing a page. For instance, if a page’s content stream is encoded with some new type of filter, there is no way for an earlier version of conforming reader to view or print the page, even though the content stream (if decoded) would be perfectly understood by the reader. There is little choice but to give an error in cases like these. Such new features are forward-compatible but not backward-compatible.
In a few cases, new features are defined in a way that earlier versions of conforming readers will ignore, but the output will be degraded in some way without any error indication. If a PDF file undergoes editing by an earlier version of a conforming product that does not understand some of the features that the file uses, the occurrences of those features may or may not survive.