
Adobe Acrobat SDK
Working with Cos Objects
Developing Plug-ins and Applications
Working with Cos strings 183
Cos streams
A stream is a sequence of bytes that can be read a portion at a time. For this reason, objects with
potentially large amounts of data, such as images and page descriptions, are represented as streams. A
stream consists of a dictionary followed by zero or more bytes bracketed between the keywords
stream
and
endstream
. The following example shows the basic syntax of a stream:
dictionary
stream
…Zero or more bytes…
endstream
The
stream
keyword should be followed by an end-of-line marker consisting of either a carriage return
and a line feed or just a line feed, and not by a carriage return alone. The sequence of bytes that make up a
stream is located between the
stream
and
endstream
keywords. Streams must be indirect objects and
the stream dictionary must be a direct object. For information, see
“About direct and indirect objects” on
page 179
.
Note:
For more information about streams, see the
PDF Reference
.
Working with Cos strings
This section discusses ways in which you can work with Cos strings. For information, see
“Cos strings” on
page 179
.
Creating Cos strings
You can use the Acrobat core API to create a
CosObj
object that is based on a Cos string. To create a Cos
string, perform the following tasks:
1. Create a
CosDoc
object that represents a PDF file by invoking the
PDDocGetCosDoc
method and
passing a
PDDoc
object.
2. Create a
CosObj
object that is based on a Cos string by invoking the
CosNewString
method and
passing the following arguments:
●
A
CosDoc
object.
●
An
ASBool
object that specifies whether the
CosObj
object is an indirect or direct object. If
true
,
the string is an indirect object. If
false
, the string is a direct object. For information, see
“About
direct and indirect objects” on page 179
.
●
A character pointer that specifies the string. Cos strings can contain NULL characters.
●
The length of the character pointer.
The following code example creates a
CosObj
that is based on a Cos string. A
PDDoc
object named
myPDDoc
is passed to the
PDDocGetCosDoc
method. For information, see
“Creating a PDDoc object” on
page 83
.
Example 17.1
Creating a Cos string
//Create a new Cos string
char* mystr = "New String";
CosDoc cd = PDDocGetCosDoc(myPDDoc);
CosObj strObj = CosNewString(cd, false, mystr, strlen(mystr));