41
1.3.2.8 Null object
The null object, denoted by the keyword null, is unequal in type to any other object. Indirect
object references to any nonexistent object are the same as null object. When specified as a
value within a dictionary object, the value should be treated as if it doesn't exist.
1.3.3 Cross-reference table
The cross-reference table consists of links to all the indirect objects in a PDF file. Each line of
the table specifies the location of a single object within the body of the document. The objects
can be accessed randomly, which means that it isn't necessary to read the entire file when
attempting to locate a particular object. Beginning with PDF 1.5 the cross-reference
information (or part of it) may also be contained in cross-reference streams.
The table consists of one or more cross-reference sections. Initially, the table has a
single section and each time the file is incrementally updated one new section is created. The
cross-reference section begins with a line containing the keyword xref, followed by one or
more cross-reference subsections. If a file has never been incrementally updated it contains a
single subsection numbered 0. The advantage of using the subsection structure is that a new
cross-reference section can simply be added when we delete or add new objects.
The subsections begin with a line of a form 'X Y', where X is a number of the first
object in the subsection and Y is the number of entries in the subsection. This line is then
followed by the cross-reference entries, one on each line, each 20 bytes long. There are two
types of entries: one indicating objects that are in use and another for deleted objects. Both
entry types have similar formats:
[10-digit number] [5-digit number] [f or n] [2 end-of-line characters]
The entry starts with 10-digit number denoting byte offset in the decoded stream (padded
with leading zeros if needed) for objects that are in use or object number of the next free
object for a free object entry, followed by a space and 5-digit generation number, then
separated by another space is character n for objects that are in use or character f indicating
free entry. The entry is closed by 2 end-of-line characters.
The free entries in the cross-reference table form a linked list, where each entry
specifies the number of the next one. The first entry in the table is always free, has generation
number 65535 and represents the head of the linked list. Conversely, the tail of the list points
back to object number 0 (the head of the list). Optionally, the free entries can point back to
object number zero and have generation number 65535 (they are not a part of the linked
list).The generation number is initially set to 0 for all entries in the cross-reference table with
the exception of object number 0. Upon deletion of an indirect object, the corresponding
entry in the cross-reference table is marked as free and the generation number is incremented
by 1. The incremented value indicates what generation number should be used next time an
object with the same object number is created. The maximum value a generation number can
reach is 65535. Entries that reach the maximum value cannot be reused.
Following is a simple example of what a cross-reference section of a PDF file might
look like:
16