Graphics Programs Reference
In-Depth Information
CHAPTER 5
Graphics
In this chapter, we'll run through the main ways to build graphics in the content stream
of a PDF page. All of the examples are based on the same PDF we created manually in
Chapter 2
and processed into valid PDF documents with
pdftk
in the same fashion. All
the examples are included in the online resources.
Looking at Content Streams
A PDF page is made up of one or more
content streams
, defined by the
/Contents
entry
in the page object, together with a shared set of resources, defined by the
/Resources
entry. In all our examples, there will only be a single content stream. Multiple content
streams are equivalent to a single stream containing their concatenated content.
Here's an example page, with no resources and a single content stream:
3 0 obj
<<
/Type /Page
/Parent 1 0 R
/Resources << >>
/MediaBox [ 0 0 792 612 ]
/Rotate 0
/Contents [ 2 0 R ]
>>
endobj
Here's the associated content stream, consisting of the
stream dictionary
and the
stream
data
.
2 0 obj
<< /Length 18 >>
Stream dictionary
stream
200 150 m 600 450 l S
Stream data
endstream
endobj