内容流

内容流是描述页面和其他图形元素外观的主要手段。内容流取决于包含在相关联的资源字典中的信息;

内容流是一个PDF流对象,其数据由描述页面上要绘制的图形元素的一系列指令组成的。instructions以PDF对象的形式表示,使用与PDF文件其余部分相同的对象语法。然而,鉴于文件作为一个整体是一个静态、随机访问的数据结构,内容流中的对象应按顺序进行解释和操作。

Each page of a document shall be represented by one or more content streams. Content streams shall also be used to package sequences of instructions as self-contained graphical elements, such as forms (see 8.10, "Form XObjects"), patterns (8.7, "Patterns"), certain fonts (9.6.5, "Type 3 Fonts")

A content stream, after decoding with any specified filters, shall be interpreted according to the PDF syntax rules described in 7.2, "Lexical Conventions." It consists of PDF objects denoting operands and operators. The operands needed by an operator shall precede it in the stream. 

操作数是属于任何基本PDF数据类型(流除外)的直接对象。字典只能由某些特定的运算符作为操作数。不允许使用间接对象和对象引用。

运算符是一个PDF关键字,用于指定应执行的某些操作,例如在页面上绘制图形形状。运算符关键字与名称对象的区别在于缺少初始固形字符(2Fh)(/)。运算符只能在内容流中有意义。

在PDF中,运算符所需的所有操作数都应紧跟在该运算符之前。运算符不返回结果,并且当运算符完成执行时,不应留下操作数。

 

资源字典

在内容流中提供给运算符的操作数只能是直接对象;不允许使用间接对象和对象引用。在某些情况下,运算符应引用在内容流之外定义的PDF对象,例如字体词典或包含图像数据的流。这应通过定义命名资源(named resources )等对象并从内容流中按名称引用这些对象来实现。

Named resources shall be meaningful only in the context of a content stream. The scope of a resource name shall be local to a particular content stream and shall be unrelated to externally known identifiers for objects such as fonts。

A content stream's named resources shall be defined by a resource dictionary, which shall enumerate the named resources needed by the operators in the content stream and the names by which they can be referred to.

资源词典应通过以下方式之一与内容流相关联:

•对于作为页面内容条目值的内容流(或作为该条目值的数组元素),资源字典应由页面字典的资源指定,或如7.7.3.4“页面属性继承”所述,从页面对象的某个祖先节点继承。For a content stream that is the value of a page's Contents entry (or is an element of an array that is the value of that entry), the resource dictionary shall be designated by the page dictionary's Resources or is inherited, as described under 7.7.3.4

•对于其他内容流,一致性编写者应在流字典中包含资源条目,指定包含该内容流使用的所有资源的资源字典。这应适用于定义表单XObject、模式、类型3字体和注释的内容流。For other content streams, a conforming writer shall include a Resources entry in the stream's dictionary specifying the resource dictionary which contains all the resources used by that content stream. 

•按照早期版本的PDF编写的PDF文件可能忽略了页面上使用的所有表单XObject和Type 3字体中的资源条目。从这些表格和字体中引用的所有资源都应从使用它们的页面的资源字典中继承。此结构已过时,合格的编写者不应使用。

 

在给定内容流的上下文中,术语current resource dictionary指以上述方式之一与流关联的资源字典。

资源字典中的每个键应为资源类型的名称,如表33所示。相应值应如下所示:

•对于资源类型ProcSet,该值应为程序集名称数组

•对于所有其他资源类型,该值应为子字典。子词典中的每个键应为特定资源的名称,相应的值应为与该名称关联的PDF对象。

axios 预览pdf文件流 pdf内容流_运算符

axios 预览pdf文件流 pdf内容流_mupdf_02

 

通用数据结构

如本条开头所述,有一些通用数据结构是根据7.3“对象”中描述的基本对象类型构建的,在整个PDF中的许多地方都使用这些数据结构。本小节描述text strings, dates, rectangles, name trees, and number trees的数据结构。7.10“函数”和7.11“文件规范”中描述了更复杂的数据结构

所有这些数据结构仅作为文档层次结构的一部分有意义;它们可能不会出现在内容流中。 

 

axios 预览pdf文件流 pdf内容流_数据结构_03

 

axios 预览pdf文件流 pdf内容流_运算符_04