
Adobe Acrobat SDK
Creating 3D Annotations
Developing Plug-ins and Applications
Specifying the 3D stream 206
Other entries are unique to 3D streams (see Table 9.35 in the
PDF Reference
). They include:
●
Type
(optional): Must be
3D
if present.
●
Subtype
(required): Must be
U3D
.
●
OnInstantiate
(optional): A JavaScript script to be executed when the 3D stream is read. For
information, see
“Specifying JavaScript code” on page 208
.
Creating the stream object
You must create a Cos stream that is based on the file containing the U3D data (this file was created with
3D authoring software) in order to create a 3D annotation. A data stream can be a buffer in memory, a file,
or an arbitrary user-written procedure. A stream is represented by an
ASStm
object, which must be
converted into a Cos stream.
To create a Cos stream that is based on the file containing the U3D data, perform the following tasks:
1. Create an
ASPathName
object that represents the file containing the U3D data by invoking the
ASPathFromPlatformPath
method and passing a character pointer that specifies the location of
the file containing U3D data. If you are working on the Mac OS platform, then invoke the
GetMacPath
method and pass a character pointer that specifies the file location.
2. Declare an
ASFile
object.
3. Populate the
ASFile
object with the file containing the U3D data by invoking the
ASFileSysOpenFile
method and passing the following arguments:
●
An
ASFileSys
object that represents the file system in which the PDF file is located. Invoke the
ASGetDefaultFileSys
method to get the default file system.
●
An
ASPathName
object that represents the path in which the file containing the U3D data is
located (pass the
ASPathName
object created in step 1).
●
An
ASFileMode
object that represents the mode in which to open the file. For example, specify
ASFILE_READ
to open the file in read mode.
●
The address of an
ASFile
object. This method populates this argument with the file that was
opened (file information is obtained from the
ASPathName
object).
4. Create an
ASStm
object by invoking the
ASFileStmRdOpen
method and passing the following
arguments:
●
The
ASFile
object with the file containing the U3D data.
●
Length of data buffer, in bytes. If you specify
0
, then the default buffer size (currently 4kB) is used.
5. Invoke the
CosNewStream
method to create a Cos stream containing the data that is located within
the
ASStm
object. This Cos stream will become the value of the 3DD entry of the 3D annotation. Pass
the following arguments to this method:
●
A
CosDoc
object that specifies the PDF document in which the Cos stream is inserted.
●
An
ASBool
object that specifies whether the Cos stream is an indirect object. Because all streams
are indirect objects, this argument must be set to
true
.
●
An
ASStm
object that contains the stream data (pass the
ASStm
object created in step 4).
●
A
CosStreamStartAndCode
object that specifies the byte offset from which data reading starts.
You can pass
0
to ensure that data reading starts at the beginning of the stream.
●
An
ASBool
object that specifies whether the data is encoded using filters specified in the stream
dictionary before it is written to the Cos stream.