Graphics Programs Reference
In-Depth Information
Graphical Content
The
page contents stream
contains a sequence of operators for placing text and graphics
on the page. It was linked to by the
/Contents
entry in the page dictionary.
A stream object consists of a dictionary followed by a raw data stream, containing a
series of PDF operands and operators. Normally, this would be compressed to reduce
file size, but we're typing it in manually, so we don't compress it. We must also specify
the length of the stream in bytes—
pdftk
will add the required
/Length
entry to the stream
dictionary for us.
4 0 obj
The page contents stream
<< >>
stream
Beginning of stream
1. 0. 0. 1. 50. 700. cm
Position at (50, 700)
BT
Begin text block
/F0 36. Tf
Select /F0 font at 36pt
(Hello, World!) Tj
Place the text string
ET
End text block
endstream
End of stream
endobj
The result of this stream of graphics operators on the page is shown in
Figure 2-2
.
Catalog, Cross-Reference Table, and Trailer
The last part of the file starts with the
document catalog
, which is the root object of the
object graph. There follows the
cross-reference table
, which gives the byte offsets of
each object in the file. We'll have
pdftk
fill this in for us. There are two final lines: one
gives the byte offset of the start of the cross-reference table (we write
0
and
pdftk
will
replace it for us). Finally, the end-of-file marker
%%EOF
.
5 0 obj
<< /Type /Catalog
The document catalog
/Pages 1 0 R
Reference to the page list
>>
endobj
xref
Start of cross-reference table, which we have missed out
0 6
trailer
<< /Size 6
Number of lines in cross-reference table (number of objects plus one)
/Root 5 0 R
Reference to the document catalog
>>
startxref
0
Byte offset of start of xref table, which we have set to 0
%%EOF
End of file marker
Now we're ready to put these pieces together.