
Adobe Acrobat SDK
Working with Cos Objects
Developing Plug-ins and Applications
Working with Cos streams 190
Working with Cos streams
This section discusses ways in which you can work with Cos streams. For information, see
“Cos streams” on
page 183
.
A stream is represented by an
ASStm
object definition. A data stream can be a buffer in memory, a file, or
an arbitrary user-written procedure. When writing or extracting data streams, an
ASStm
object must be
converted to a Cos stream.
Note:
Before reading this section, it is strongly recommended that you are familiar with concepts
discussed earlier in this chapter such as Cos arrays and Cos dictionaries.
Creating Cos streams
You can create a data stream in memory and then insert the stream into a PDF document page. The
following diagram shows the result of a data stream that creates a thin black line segment being inserted
into a PDF document.
The following example shows the syntax of a stream that creates a thin line segment:
150 250 m 150 350 l S
In contrast, the following example shows the syntax of a stream that inserts the text
Hello
There
into a
PDF document:
BT /F0 1 Tf 24 0 0 24 36 756 Tm 0 Tr 0 g 0 Tc 0 Tw \(Hello There) Tj ET
Note:
For information about stream syntax, see the
PDF Reference
.
Creating a stream dictionary
Each Cos stream has a stream dictionary that contains a
Length
entry that indicates how many bytes are
used for the stream’s data (if the stream has a filter, the
Length
entry is the number of bytes of encoded
data). A limit of 4096 bytes exists for the
Length
entry. A stream dictionary also has optional entries that
are not discussed in this section. For more information about stream dictionaries, see the
PDF Reference
.