DL Logo

ASStm Typedefs

ASSmallBufferSize

Header: ASExpT.h:174

Description

May not be larger than int16.

Syntax

typedef ASUns16 ASSmallBufferSize;

Used By

ASStmRec

Header: ASExpT.h:305

Description

A stream object definition (see ASStream.h). It is a data stream that may be a buffer in memory, a file, or an arbitrary user-written procedure. It is typically used to extract data from a PDF file. When writing or extracting data streams, the ASStm must be connected to a Cos stream.

Syntax

typedef struct _t_ASStmRec ASStmRec, *ASStm;

Returned From

Used By

Used In

ASStm Callback Signatures

ASProcStmDestroyProc

Header: ASExpT.h:533

Description

A callback for use by ASProcStmWrOpen() and ASProcStmRdOpenEx().

This is called at the end of the stream so you can do clean up and free allocated memory.

Syntax

void ASProcStmDestroyProc(void *clientData);

Parameters

clientData
IN/OUT User-supplied data that was passed in the call to ASProcStmWrOpen() or ASProcStmRdOpenEx().

Used By

Used In

ASProcStmGetLength

Header: ASExpT.h:564

Description

A callback for use by ASProcStmRdOpenEx().

This is called to get the length of the stream, which may be NULL if the stream cannot be set to a new position. ASProcStmSeekProc() and ASProcStmGetLength() must be provided together. If either is NULL, the stream will not be set to a new position.

Syntax

ASFilePos64 ASProcStmGetLength(void *clientData);

Parameters

clientData
IN/OUT User-supplied data that was passed in the call to ASProcStmRdOpenEx().

Returns

The length of the stream in bytes.

Used In

ASProcStmSeekProc

Header: ASExpT.h:549

Description

A callback for use by ASProcStmRdOpenEx().

This is called to set the stream position to a new location, which may be NULL if the stream cannot be set to a new position. ASProcStmSeekProc() and ASProcStmGetLength() must be provided together. If either is NULL, the stream will not be set to a new position.

Syntax

void ASProcStmSeekProc(ASFilePos64 newPos, void *clientData);

Parameters

newPos
clientData
IN/OUT User-supplied data that was passed in the call to ASProcStmRdOpenEx().

Used In

ASStmProc

Header: ASExpT.h:519

Description

A callback for use by ASProcStmRdOpenEx() and ASProcStmWrOpen(). This should place data in the buffer specified by the parameter data.

If your procedure reads data from a file, it is generally quite inefficient to open the file, read the bytes, and close the file each time bytes are requested. Instead, consider opening the file the first time bytes are requested from it, reading the entire file into a secondary buffer, and closing the file. When subsequent requests for data from the file are received, simply copy data from the secondary buffer, rather than reopening the file.

Syntax

ASTCount ASStmProc(char *data, ASTArraySize nData, void *clientData);

Parameters

data
(Filled by the callback) The buffer into which your procedure must place the number of bytes specified by nData.
nData
The number of bytes to read from the stream and place into data.
clientData
User-supplied data that was passed in the call to ASProcStmRdOpenEx() or ASProcStmWrOpen().

Returns

The number of bytes actually read or written. This should be equal to the nData parameter unless the end of file marker (EOF) has been reached, an error has occurred, or this is short block of data just before EOF. If EOF has been reached, a zero should be returned. If an error has occurred, a negative value should be returned.

Used By

Used In

ASStm Structures

_s_ASProcStmRdExHandler

Header: ASExpT.h:567

Description

For use by ASProcStmRdOpenEx().

Syntax

struct _s_ASProcStmRdExHandler {
Set to sizeof(ASProcStmRdExHandlerRec).
ASStmProc readProc;
ASProcStmDestroyProc destroyProc;
ASProcStmGetLength getLengthProc;
ASByteCount bufSize;
The size of the buffer to use for the stream. If this field is missing, the default is 65535. If this field is present and has a value of 0, then the default is implementation-specific.
} ASProcStmRdExHandlerRec, *ASProcStmRdExHandler;

Used By

ASStm Functions

ASMemStmRdOpen

Header: ASProcs.h:1086

Description

Creates a read-only ASStm from a memory-resident buffer. The stream supports seek operations.

Syntax

ASStm ASMemStmRdOpen(const char *data, ASArraySize len);

Parameters

data
A buffer containing the data to read into the stream. This data buffer must not be disposed of until the ASStm is closed.
len
The length in bytes of data.

Returns

The newly created ASStm.

ASProcStmRdOpen

Header: ASProcs.h:1107

Description

Creates a read-only ASStm from an arbitrary data-producing procedure. The stream does not support seek operations.

readProc is called when the client of the stream attempts to read data from it.

Syntax

ASStm ASProcStmRdOpen(ASStmProc readProc, void *clientData);

Parameters

readProc
A user-supplied callback that supplies the stream's data.
clientData
A pointer to user-supplied data to pass to readProc each time it is called.

Returns

The newly created ASStm.

Exceptions

ASProcStmRdOpenEx

Header: ASProcs.h:2148

Description

Extends ASProcStmRdOpen() and creates a read-only ASStm from an arbitrary data-producing procedure. The stream optionally supports seek operations, although external clients do not have the ability to initiate a seek operation.

The supplied handlers are called when the client of the stream attempts to read data from it, seek it, or find it's length, as well as when the client closes it.

Syntax

ASStm ASProcStmRdOpenEx(ASProcStmRdExHandler handler, void *clientData);

Parameters

handler
A structure containing user-supplied callbacks that supply the stream's data and destroy the stream.
clientData
A pointer to user-supplied data to pass to the procedures each time they are called.

Returns

The newly created ASStm.

Exceptions

ASProcStmWrOpen

Header: ASProcs.h:1538

Description

Creates an ASStm from an arbitrary data-producing procedure. The stream does not support seek operations.

Syntax

ASStm ASProcStmWrOpen(ASStmProc writeProc, ASProcStmDestroyProc destroyProc, void *clientData);

Parameters

writeProc
A user-supplied callback that provides the data for the stream.
destroyProc
A user-supplied callback that destroys the specified ASStm. (Generally, this means deallocating the memory associated with the ASStm.)
clientData
A pointer to user-supplied data to pass to writeProc each time it is called.

Returns

The newly created ASStm.

Exceptions

ASStmClose

Header: ASProcs.h:1167

Description

Closes the specified stream.

Syntax

void ASStmClose(ASStm stm);

Parameters

stm
The stream to close.

ASStmFlush

Header: ASProcs.h:2458

Description

Flushes any buffered data to the specified stream.

Related Methods

Syntax

ASTCount ASStmFlush(ASStm stm);

Parameters

stm
The stream to flush.

Returns

0 if successful, non-zero otherwise.

ASStmRead

Header: ASProcs.h:1126

Description

Reads data from stm into memory.

Related Methods

Syntax

ASTCount ASStmRead(char *ptr, ASTArraySize itemSize, ASTCount nItems, ASStm stm);

Parameters

ptr
(Filled by the method) A buffer into which data is written.
itemSize
The number of bytes in a stream item. See the description of nItems for further information.
nItems
The number of items to read. The amount of data read into the memory buffer will be itemSize * nItems, unless an EOF is encountered first. The relative values of itemSize and nItems really do not matter; the only thing that matters is their product. It is often convenient to set itemSize to 1, so that nItems is the number of bytes to read.
stm
The stream from which data is read.

Returns

The number of items (not bytes) read.

ASStmWrite

Header: ASProcs.h:1156

Description

Writes data from a memory buffer into an ASStm.

You cannot use this method to change a PDF page content stream. It can only be used for a print stream.

.

Historically, this method was provided to allow plug-ins to write data into the print stream when printing to a PostScript printer (see the PDDocWillPrintPage() notification). However, ASStm is a general purpose I/O mechanism in Acrobat even though only limited open and read/write methods are provided in the plug-in API. For instance, not all ASStm objects support seek operations.

Related Methods

Syntax

ASTCount ASStmWrite(const char *ptr, ASTArraySize itemSize, ASTCount nItems, ASStm stm);

Parameters

ptr
A buffer from which data is read.
itemSize
The number of bytes in a stream item. See the description of nItems for additional information.
nItems
The number of items to write. The amount of data written into the stream will be itemSize * nItems. The relative values of itemSize and nItems really do not matter; the only thing that matters is their product. It is often convenient to set itemSize to 1, so that nItems is the number of bytes to read.
stm
The stream into which data is written.

Returns

The number of items (not bytes) written.