The eight object types
| Type | Syntax | Notes |
|---|---|---|
| Boolean | true false | |
| Numeric | 42 -3 3.14 .5 | Integer and real. No exponent notation (1e5 is invalid). |
| String | (Hello \(world\)) <48656C6C6F> | Literal or hex. Bytes, not characters: interpretation depends on context (PDFDocEncoding, UTF-16BE with BOM, font encoding). |
| Name | /Type /Font /A#20B | Atoms used as keys and enum values. #xx escapes a byte (1.2+). |
| Array | [0 0 612 792] | Heterogeneous; may nest. |
| Dictionary | << /Type /Page /Rotate 90 >> | Keys are names. A key with value null is the same as an absent key. |
| Stream | << /Length 41 >> stream … endstream | A dictionary followed by a byte sequence. Always an indirect object. |
| Null | null |
Read:
Indirect objects and references
Any object can be given an identity, an object number plus a generation number, and then referred to from anywhere:
12 0 obj % define object 12, generation 0 << /Type /Font /Subtype /Type1 /BaseFont /Helvetica >> endobj << /Font << /F1 12 0 R >> >> % "12 0 R" = reference to that object
The generation number only increases when an object number is freed and reused. In practice it is almost always 0.
Streams and filters
Streams hold the bulk data: page content, images, fonts, metadata. /Filter names the encoding to undo, and filters can be chained ([/ASCII85Decode /FlateDecode]), applied in order when decoding.
4 0 obj << /Length 1532 /Filter /FlateDecode >> stream …1532 bytes of zlib data… endstream endobj
| Filter | Use | Since |
|---|---|---|
FlateDecode | zlib/deflate; the default for almost everything. Supports PNG predictors via /DecodeParms. | 1.2 |
DCTDecode | Baseline JPEG images | 1.0 |
CCITTFaxDecode | Group 3/4 fax, bilevel scans | 1.0 |
JBIG2Decode | Better bilevel compression | |
JPXDecode | JPEG 2000 | 1.5 |
Crypt | Per-stream crypt filter selection | 1.5 |
ASCIIHexDecode, ASCII85Decode, LZWDecode, RunLengthDecode | Legacy and 7-bit-safe encodings | 1.0 |
The Filters reference has every filter with its parameters.
Read:
/Length may itself be an indirect reference (/Length 7 0 R), because a writer streaming output doesn't know the length until it has written the data. Robust parsers also cope with a wrong /Length by scanning for endstream.