interaction-annotations.tex /size: 3818 b    last modification: 2023-12-21 09:43
1% language=us
2
3\environment interaction-style
4
5\startcomponent interaction-annotations
6
7\startchapter[title=Annotations]
8
9Before we discuss interactive features (in following chapter) a few words will be
10spent on so called annotations. This term is used in Acrobat and is somewhat
11confusing as hyperlinks conceptually are not really annotations while comments
12are. The term relates to the way \PDF\ files can have added functionality. It
13might help understand the following chapters better when you know what model is
14used inside a \PDF.
15
16If you open a \PDF\ file in an editor you will finds lots of objects. Numbers are
17an object, as are strings and booleans. Symbols (represented as strings with a
18leading slash) are also objects. Objects can be collected in indexed tables
19(arrays) and hash tables (dictionaries). Serialized arrays are bounded by square
20brackets:
21
22\starttyping
23[ (value1) (value2) ]
24[ 1 2 3 ]
25[ 1 2 (value1) (value3) true /foo ]
26\stoptyping
27
28and hashes by double angle brackets:
29
30\starttyping
31<<
32    /Key1 (value1)
33    /Key2 (value2)
34    /Key3 123
35    /Key4 true
36    /Key5 [ 1 2 3 4 ]
37>>
38\stoptyping
39
40A \PDF\ file is a collection of objects:
41
42\starttyping
431 0 obj
44    ...
45endobj
46\stoptyping
47
48Instead of a number, string, boolean, array or dictionary an object can also be
49a stream of bytes:
50
51\starttyping
521 0 obj << /Length 123 >>
53stream
54... 123 bytes ...
55endstream
56endobj
57\stoptyping
58
59Objects can refer to each other and can be looked up via a so called xref table.
60We refer to object with number one and revision zero as follows:
61
62\starttyping
63/foo 1 0 R
64\stoptyping
65
66When an object is updated it can be added to the end of the file and the version
67number can get bumped. A program that does something with the \PDF\ is supposed
68to do something clever with these numbers. More often the revision stays zero.
69
70A document is normally a sequence of pages. When a file is opened the cross
71reference table is loaded and the so called catalog is looked up. From there
72pages can be found. Pages have a content stream and can refer to resources, like
73fonts, special color spaces, complex objects (xforms) and among other things
74annotations.
75
76The page is rendered from the content stream but that stream has no information
77about hyperlinks and such. The \type {/Link} annotation objects that implement
78interactivity are independent and kind of layered over the rendered page. They
79describe rectangular areas that a viewer can use to intercept mouse clicks. If
80you want to see where the actions happens, search for \type {/Dest} and \type
81{/Annot} in an (uncompressed) \PDF file. When you process a file with
82
83\starttyping
84\nopdfcompression
85\stoptyping
86
87you get an uncompressed file and with an appropriate editor you can see where
88annotations end up.
89
90The main reason for mentioning these details is that when you are checking a file
91for problems you need to look for annotation objects instead of the page stream.
92You also need to realize that these annotations in no way interfere with the page
93stream. They only exist because a viewer can use that information to add
94functionality. Their reference point is the lower left corner of the page. This
95is a conceptual difference with \HTML\ where hyperlinks are often in|-|line and
96part of the content stream. Both approaches have their advantages and
97disadvantages. From the perspective of quality typesetting it makes much sense to
98have them overlayed and explicitly defined (in terms of dimensions) but users
99will of course in most cases define them inline. This means that in order to make
100the \PDF\ some analyzing and juggling has to take place. In \CONTEXT\ we always
101have done as much as possible at the \TEX\ (therefore bypassing some limitations
102in the engine) end in \MKIV\ we don't use the engine's features at all.
103
104\stopchapter
105
106\stopcomponent
107