PDF dictionary object logic

50 Views Asked by At

I'm struggling to understand the logic of PDF dictionary objects.

From 1.4 specs:

A dictionary object is an associative table containing pairs of objects, known as the dictionary’s entries. The first element of each entry is the key and the second element is the value. The key must be a name [cut]. The value can be any kind of object, including another dictionary. A dictionary entry whose value is null [cut] is equivalent to an absent entry.

It doesn't specify HOW the entries are separated.

Example 1: /Type /Example /Subtype /DictionaryExample /Version 0.01 /IntegerItem 12 /StringItem (a string)

Example 2: /Type/Font/Subtype/Type0/BaseFont/BCDEEE+Calibri-Light/Encoding/Identity-H/DescendantFonts 6 0 R/ToUnicode 17 0 R

Example 3: /Filter/FlateDecode/Length 344

Example 4: /Type/XRef/Size 25/W[ 1 4 2] /Root 1 0 R/Info 16 0 R/ID[<288F58E840FA0549B84588E3C9928D88><288F58E840FA0549B84588E3C9928D88>] /Filter/FlateDecode/Length 98

From examples 1 and 2 you can clearly see that the first key "Type" have the value "Example" and "Font". The second key is "Subtype" for both.

It seems the key and value of each entry is stored just one after the other, and separate by a "/".

In example 3 we have the entry with key "Length" and its value "344". This breaks the rule of the "/" as separator of entries and values.
Maybe a space after the key name means the value is "inside" the item (the string between 2 "/"), but this rule is broken by the example 1 where "Type" is followd by a space (that example is from the spec itself).

And then there is example 4 with "W[ 1 4 2] ".
I assumet he key is "W" and the value is an array of 3 integers.
What rule "define" the key is "W" and not "W[" ?
Why there is a space after the array ?

I only read 40-50 pages of the specs, not all the thousands pages document but I read the "Dictionary Objects" paragraph (3.2.6) and I expected there it should explain HOW to split/parse the entries.

What is the logic to apply or where to find it properly defined ?

0

There are 0 best solutions below