Layer

COS Layer

12 components137 items
109 Functions 7 Definitions 19 Typedefs 1 Structures 1 Enums

CosArray

9 items

Functions(9)

CosArrayInsert

CosProcs.h:844

Inserts an object into an array. An exception is raised if the object to insert is a direct object that is already contained in another object, or if the object to insert belongs to another document. It is not safe to call CosArrayInsert() during a call to CosObjEnum() on that same array (for example, from within the callback procedure).

Parameters
array: CosObj

The array into which the object is inserted.

pos: ASTArraySize

The location in the array to insert the object. The object is inserted before the specified location. The first element in an array has a pos of zero. If pos >= CosArrayLength(array) , obj is added at the end of the array. The length of the array always increases by 1 .

obj: CosObj

The object to insert.

Returns
void

CosArrayIsWeakReference

CosProcs.h:2110

Return the state of a weak reference in an array. See CosDictIsWeakReference() for details.

Parameters
array: CosObj

An array.

n: ASInt32

The index of an item in the array.

Returns
ASBool

Returns the value of the isWeak parameter in the most recent call to CosArraySetWeakReference() with these parameters, or false if there has been no such call.

CosArrayPut

void CosArrayPut(CosObj array, ASTArraySize index, CosObj obj)
CosProcs.h:818

Puts the specified object into the specified location in an array. The array is extended as much as necessary and NULL objects are stored in empty slots. It sets the PDDocNeedsSave flag (see PDDocSetFlags ) flag of the array object's CosDoc if array is indirect or is a direct object with an indirect composite object at the root of its container chain. It is not safe to call CosArrayPut() during a call to CosObjEnum() on that same array (for example, from within the callback procedure), if doing so would extend the length of the array. An exception is raised if the object to insert is a direct object that is already contained in another object, or if the object to insert belongs to another document.

Parameters
array: CosObj

The array in which obj is stored.

index: ASTArraySize

The location in array to store obj . The first element of an array has an index of zero.

obj: CosObj

The Cos object to insert into array .

Returns
void

CosArrayRemove

void CosArrayRemove(CosObj array, CosObj obj)
CosProcs.h:865

Finds the first element, if any, equal to the specified object and removes it from the array. CosObjEqual() is used to determine whether an array element is equal to the specified object. The array is compressed after removing the element. The compression is accomplished by moving each element following the deleted element to the slot with the next smaller index and decrementing the array's length by 1 . It is not safe to call CosArrayRemove() during a call to CosObjEnum() on that same dictionary (for example, from within the callback procedure).

Parameters
array: CosObj

The array from which obj is removed.

obj: CosObj

The object to remove.

Returns
void
See Also

CosArrayRemoveNth

CosProcs.h:1344

Checks whether the position is within the array bounds, removes it from the array, moves each subsequent element to the slot with the next smaller index, and decrements the array's length by 1. It sets the dirty flag of the array object's CosDoc .

Parameters
array: CosObj

IN/OUT The CosArray from which to remove the member.

pos: ASTArraySize

IN/OUT The index for the array member to remove. Array indices start at 0 .

Returns
void
See Also

CosArraySetWeakReference

CosProcs.h:2099

Establishes or removes a weak reference from an array. For a description of weak references, see CosDictSetWeakReference() .

Parameters
array: CosObj

An array.

n: ASInt32

The index of the element that is the weak reference. Note that the weak reference travels with the element; that is, if an item is marked as a weak reference, and an item is subsequently inserted before that item, the weak reference applies to the same element as it did previously.

isWeak: ASBool

Sets a weak reference for an array.

Returns
void

CosNewArray

CosObj CosNewArray(CosDoc dP, ASBool indirect, ASTArraySize nElements)
CosProcs.h:255

Creates and returns a new array Cos object.

Parameters
dP: CosDoc

The document in which the array is used.

indirect: ASBool

If true , it creates the array as an indirect Cos object, and sets the document's PDDocNeedsSave flag (see PDDocSetFlags ). If false , it creates the array as a direct object.

nElements: ASTArraySize

The number of elements that will be in the array. nElements is only a hint; Cos arrays grow dynamically as needed.

Returns
CosObj

The newly created array Cos object.

CosBoolean

2 items

Functions(2)

CosNewBoolean

CosObj CosNewBoolean(CosDoc dP, ASBool indirect, ASBool value)
CosProcs.h:194

Creates a new boolean object associated with the specified document and having the specified value.

Parameters
dP: CosDoc

IN The document in which the boolean is used.

indirect: ASBool

IN If true , it creates the boolean object as an indirect object, and sets the document ( dP ) object's PDDocNeedsSave flag (see PDDocFlags ). If false , it creates the boolean object as a direct object.

value: ASBool

IN The value the new boolean object will have.

Returns
CosObj

A Cos boolean object.

CosCrypt

7 items

Functions(5)

CosDecryptData

void CosDecryptData(void *src, ASTArraySize len, void *dst, char *cryptData, ASTArraySize cryptDataLen)
CosProcs.h:1005

Decrypts data in a buffer using the specified encryption key. The standard Acrobat viewer encryption/decryption algorithm (RC4 from RSA Data Security, Inc.) is used. An exception is raised if encryption encounters an internal error.

Parameters
src: void *

The buffer containing the data to decrypt.

len: ASTArraySize

The number of bytes in src .

dst: void *

(Filled by the method) The buffer into which the decrypted data will be placed. This may point to the same location as src .

cryptData: char *

The encryption key.

cryptDataLen: ASTArraySize

The length of the encryption key in bytes. It cannot be greater than 5 .

Returns
void
See Also

CosEncryptData

void CosEncryptData(void *src, ASTArraySize len, void *dst, char *cryptData, ASTArraySize cryptDataLen)
CosProcs.h:1027

Encrypts data in a buffer using the specified encryption key. The standard Acrobat viewer encryption/decryption algorithm (RC4 from RSA Data Security, Inc.) is used. An exception is raised if encryption encounters an internal error.

Parameters
src: void *

The buffer containing the data to encrypt.

len: ASTArraySize

The number of bytes in src .

dst: void *

(Filled by the method) The buffer into which the encrypted data will be placed. This may point to the same location as src .

cryptData: char *

The encryption key.

cryptDataLen: ASTArraySize

Length of the encryption key, in bytes. It cannot be greater than 5 .

Returns
void
See Also

Typedefs(2)

CosDict

15 items

Functions(15)

CosDictGet

CosProcs.h:633

Gets the value of the specified key in the specified dictionary. If it is called with a stream object instead of a dictionary object, this method gets the value of the specified key from the stream's attributes dictionary.

<b>Key Names:</b> Even though key names in a PDF file are written with a leading slash (e.g., <</Length 42>>), the slash is omitted when creating an ASAtom to be used as a key, or when using the string directly as a key, as in the examples above.

Cos name objects can also be used as keys, by calling CosDictGetKey(). This method will also avoid the creation of new ASAtom objects and is often more convenient than using ASAtom objects or strings.

Parameters
dict: CosObj
key: ASAtom
Returns

CosDictGetKey

CosProcs.h:1917

Gets the value of the specified key in the specified dictionary. For more details, see CosDictGet() .

Parameters
dict: CosObj

The dictionary or stream from which a value is obtained.

key: CosObj

The key whose value is obtained, represented as a Cos name object.

Returns
CosObj

The object associated with the specified key. If key is not present, it returns a NULL Cos object.

CosDictGetKeyString

CosObj CosDictGetKeyString(CosObj dict, const char *key)
CosProcs.h:1981

Gets the value of the specified key in the specified dictionary. For more details, see CosDictGet() .

Parameters
dict: CosObj

The dictionary or stream from which a value is obtained.

key: const char *

The key whose value is obtained, represented as a string.

Returns
CosObj

The object associated with the specified key. If key is not present, returns a NULL Cos object.

CosDictIsWeakReference

ASBool CosDictIsWeakReference(CosObj dict, const char *key)
CosProcs.h:2084

Gets the state of a weak reference. For details, see CosDictSetWeakReference() .

Parameters
dict: CosObj

A dictionary.

key: const char *

The name of a key.

Returns
ASBool

Returns the value of the isWeak parameter in the most recent call to CosDictSetWeakReference() with these parameters, or false if there has been no such call.

CosDictKnown

CosProcs.h:775

Tests whether a specific key is found in the specified dictionary. Calling this method is equivalent to checking if the value returned from CosDictGet() is a NULL Cos object. If it is called with a stream object instead of a dictionary object, this method tests whether the specified key is found in the stream's attributes dictionary. You can find this document on the web store of the International Standards Organization (ISO). Here you will find the names of keys in dictionary objects that are part of standard PDF, such as annotations or page objects (see CosDictGet() for Key Names ). Note that strings can be used directly as keys, by calling CosDictKnownKeyString() (for example, CosDictKnownKeyString(dict, "Length") ). This method is preferred, because it avoids the creation of new ASAtom objects. Cos name objects can also be used as keys, by calling CosDictKnownKey() . This method will also avoid the creation of new ASAtom objects and is often more convenient than using ASAtom objects or strings.

Parameters
dict: CosObj

The dictionary or stream in which to look for key .

key: ASAtom

The key to find. See the description of "Dictionary Objects" in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 7.3.7, page 18.

Returns
ASBool

true if the value of a key is known (exists and is not NULL ) in dict , false otherwise.

CosDictKnownKey

CosProcs.h:1933

Tests whether a specific key is found in the specified dictionary. Calling this method is equivalent to checking if the value returned from CosDictGetKey() is a NULL Cos object. For more details, see CosDictKnown().

Parameters
dict: CosObj

The dictionary or stream in which to look for key .

key: CosObj

The key to find, represented as a Cos name object.

Returns
ASBool

true if the value of a key is known (exists and is not NULL ) in dict , false otherwise.

CosDictKnownKeyString

ASBool CosDictKnownKeyString(CosObj dict, const char *key)
CosProcs.h:1997

Tests whether a specific key is found in the specified dictionary. Calling this method is equivalent to checking if the value returned from CosDictGetKeyString() is a NULL Cos object. For more details, see CosDictKnown() .

Parameters
dict: CosObj

The dictionary or stream in which to look for key.

key: const char *

The key to find, represented as a string.

Returns
ASBool

true if the value of a key is known (exists and is not NULL ) in dict , false otherwise.

CosDictPut

void CosDictPut(CosObj dict, ASAtom key, CosObj val)
CosProcs.h:688

Sets the value of a dictionary key, adding the key to the dictionary if it is not already present. Sets the PDDocNeedsSave flag (see PDDocSetFlags) of the dict object's CosDoc if dict is indirect or is a direct object with an indirect composite object at the root of its container chain.

This method can also be used with a stream object. In that case, the key-value pair is added to the stream's attributes dictionary.

It is not safe to call CosDictPut() during a call to CosObjEnum() on that same dictionary (for example, from within the callback procedure).

An exception is raised if val is a direct non-scalar object that is already contained in another dictionary, array, or stream, or if dict and val belong to different documents.

Parameters
dict: CosObj
key: ASAtom
val: CosObj
Returns
void

CosDictPutKey

void CosDictPutKey(CosObj dict, CosObj key, CosObj val)
CosProcs.h:1955

Sets the value of a dictionary key, adding the key to the dictionary if it is not already present. For more details, see CosDictPut().

It is not safe to call CosDictPutKey() during a call to CosObjEnum() on that same dictionary (for example, from within the callback procedure)

An exception is raised if val is a direct non-scalar object that is already contained in another dictionary, array, or stream, or if dict and val belong to different documents.

Parameters
dict: CosObj
key: CosObj
val: CosObj
Returns
void

CosDictPutKeyString

void CosDictPutKeyString(CosObj dict, const char *key, CosObj val)
CosProcs.h:2018

Sets the value of a dictionary key, adding the key to the dictionary if it is not already present. For more details, see CosDictPut().

It is not safe to call CosDictPutKey() during a call to CosObjEnum() on that same dictionary (for example, from within the callback procedure).

An exception is raised if val is a direct non-scalar object that is already contained in another dictionary, array, or stream, or if dict and val belong to different documents.

Parameters
dict: CosObj
key: const char *
val: CosObj
Returns
void

CosDictRemove

void CosDictRemove(CosObj dict, ASAtom key)
CosProcs.h:735

Removes a key-value pair from a dictionary. Sets the PDDocNeedsSave flag (see PDDocSetFlags ) of the dict object's CosDoc if the dictionary is indirect or has an indirect composite object at the root of its container chain. If it is called with a stream object instead of a dictionary object, this method removes the value of the specified key from the stream's attributes dictionary. It is not safe to call CosDictRemove() during a call to CosObjEnum() on that same dictionary (for example, from within the callback procedure). If the key is not present in the dictionary, CosDictRemove() has no effect. You can find this document on the web store of the International Standards Organization (ISO). Here you will find the names of keys in dictionary objects that are part of standard PDF, such as annotations or page objects (see CosDictGet() for Key Names ). Note that strings can be used directly as keys, by calling CosDictRemoveString() (for example, CosDictRemoveString(dict, "Length") ). This method is preferred, because it avoids the creation of new ASAtom objects. Cos name objects can also be used as keys, by calling CosDictRemoveKey() . This method will also avoid the creation of new ASAtom objects and is often more convenient than using ASAtom objects or strings.

Parameters
dict: CosObj

The dictionary from which the key-value pair is removed.

key: ASAtom

The key to remove, represented as an ASAtom. See the description of "Dictionary Objects" in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 7.3.7, page 18.

Returns
void

CosDictSetWeakReference

void CosDictSetWeakReference(CosObj dict, const char *key, ASBool isWeak)
CosProcs.h:2073

Weak and strong references. When a Cos document is saved in full-save mode, objects that are not accessible from the root of the document are destroyed. This process uses a mark-and-sweep garbage collector: the root is marked, and then every object to which it refers is marked, and so on. At the end of this marking phase, objects that are not marked are destroyed. A so-called weak reference changes this policy: during the marking phase, a reference that has been declared to be weak will not be marked. For example, when a dictionary is marked, all its keys and values are normally also marked. But if a certain key has been set as a weak reference, then the corresponding value will not be marked. Consequently, if there are no other references to that value, it will be destroyed. A so-called strong reference also changes this policy, but in the opposite direction. An object for which there is a strong reference will be marked (and therefore will not be garbage-collected), even if there is no path to the object from the root of the document, and even if a weak reference exists for it. CosDictSetWeakReference() establishes or removes a weak reference from a dictionary. It is not an error if there is no such value at the time of garbage collection or at the time of the call to this function. If isWeak is false (the default condition), then there is no such behavior, and the value, if any, will be marked in the normal manner. The case where isWeak is specified as false is intended primarily to reverse the effect of a previous call in which isWeak was true .

Parameters
dict: CosObj

The dictionary containing the weak reference.

key: const char *

The name of a key in the dictionary.

isWeak: ASBool

If true , the object stored in dict under key at the time of every subsequent full-save garbage collection will not be marked as a component of the dictionary. If there is no other path to that object from the root of the document, then it will be garbage- collected (destroyed) by garbage collection.

Returns
void

CosNewDict

CosObj CosNewDict(CosDoc dP, ASBool indirect, ASTArraySize nEntries)
CosProcs.h:283

Creates a new dictionary.

For information on dictionary objects in standard PDF files, such as annotations or page objects, see the description of "Dictionary Objects" in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 7.3.7, page 18. You can find this document on the web store of the International Standards Organization (ISO).

Parameters
dP: CosDoc
indirect: ASBool
nEntries: ASTArraySize

The number of entries in the dictionary. This value is only a hint; Cos dictionaries grow dynamically as needed.

Returns
CosObj

The newly created dictionary Cos object.

CosDoc

33 items

Functions(21)

CosDocClose

void CosDocClose(CosDoc cosDoc)
CosProcs.h:1074

Closes a Cos document. You should only call this method with a document obtained via CosDocOpenWithParams() to release resources used by the Cos document.

Parameters
cosDoc: CosDoc

IN/OUT The document to close.

Returns
void

CosDocCreate

CosProcs.h:1085

Creates an empty Cos document.

Parameters
createFlags: ASFlagBits

An inclusive OR of bit flags that specify the attributes of a CosDoc when created by CosDocCreate() . The only flag currently defined is cosDocCreateInfoDict (0x01) , which creates an Info dictionary for the document.

Returns
CosDoc

An empty Cos document.

CosDocEnumEOFs

ASBool CosDocEnumEOFs(CosDoc cosDoc, CosDocEnumEOFsProc proc, void *clientData)
CosProcs.h:1274

Calls the specified procedure for each EOF in a given CosDoc, where the EOF is a position in a PDF file after a %%EOF keyword that marks the end of either a main cross-reference section, or an update cross-reference section that corresponds to an incremental save. Not every %%EOF keyword fits these criteria. For example, the first %%EOF in a linearized (optimized for the web) file does not, so its position is not be passed to proc .

If cosDoc was created in memory (using CosDocCreate()), or if it was damaged and needed to be repaired, the procedure is not called at all.

Parameters
cosDoc: CosDoc
clientData: void *
Returns

CosDocEnumEOFs64

ASBool CosDocEnumEOFs64(CosDoc cosDoc, CosDocEnumEOFsProc64 proc, void *clientData)
CosProcs.h:2210

Calls the specified procedure for each EOF in a given CosDoc . For details, see CosDocEnumEOFs() . This is the same as CosDocEnumEOFs() , except that the callback proc takes a 64-bit file position instead of a 32-bit file position.

Parameters
cosDoc: CosDoc

The CosDoc in which the EOF's are enumerated.

proc: CosDocEnumEOFsProc64

The CosDocEnumEOFsProc64() to call for each EOF.

clientData: void *

A pointer to user-supplied data to pass to proc each time it is called.

Returns
ASBool

true if all of the calls to proc return true , false as soon as a call to proc returns false .

CosDocEnumIndirect

ASBool CosDocEnumIndirect(CosDoc dP, CosObjEnumProc proc, void *clientData)
CosProcs.h:1378

Enumerates all the indirect objects of a given CosDoc . The objects are enumerated in no particular order. Successive enumerations of the same Cos document are not guaranteed to enumerate objects in the same order. This method does not enumerate invalid objects, which include objects that are defined as NULL , objects that are not defined at all (those having no cross-reference entry), and objects that are on the free list. See the description of "Indirect Objects" in section 7.3.10 in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 7.11.2, page 21. You can find this document on the web store of the International Standards Organization (ISO). This re-raises any exception that proc raises.

Parameters
dP: CosDoc

The CosDoc whose indirect objects are enumerated.

proc: CosObjEnumProc

A user-supplied callback to call for each indirect object in dP . Enumeration ends when proc returns false or all indirect objects have been enumerated. The value parameter returned in proc is always the NULL Cos object.

clientData: void *

A pointer to user-supplied data to pass to proc each time it is called.

Returns
ASBool

true if all of the calls to proc returned true . It returns false as soon as a call to proc returns false .

See Also

CosDocGetAdobeExtensionLevel

CosProcs.h:2442

Tests whether the supplied CosDoc contains the Adobe Extensions Dictionary for the ISO 32000 standard, and if so, returns the BaseVersion and ExtensionLevel When the Extensions Dictionary is added to a PDF document, it allows PDF features provided in Adobe Acrobat after PDF version 1.7 to be used with that document. The version of the PDF file is drawn from the Extensions Dictionary instead of from the file header. See https://www.adobe.com/devnet/pdf/pdf_reference.html When the Extensions Dictionary is added to a PDF document, it allows PDF features provided in Adobe Acrobat after PDF version 1.7 to be used with that document. The version of the PDF file is drawn from the Extensions Dictionary instead of from the file header. See https://www.adobe.com/devnet/pdf/pdf_reference.html

Parameters
dP: CosDoc

IN The Cos document to test.

baseVersion: CosObj *

OUT The PDF version on which the extensions are based (will be of type CosName ).

extension: ASUns32 *

OUT The level of the extension expressed as a monotonically increasing integer.

Returns
ASBool

true if the file contains the Adobe Extensions dictionary for the ISO 32000 standard, false otherwise.

CosDocGetID

ASBool CosDocGetID(CosDoc dP, CosByte **pInstanceID, CosByte **pPermaID, ASTCount *instIDLength, ASTCount *permIDLength)
CosProcs.h:1506

Returns two ID byte arrays identifying the CosDoc. The client should copy these arrays before making the next call to Acrobat.

Parameters
dP: CosDoc

IN/OUT The CosDoc whose ID byte arrays are returned.

pInstanceID: CosByte **

IN/OUT (Filled by the method) The instance ID.

pPermaID: CosByte **

IN/OUT (Filled by the method) The permanent ID.

instIDLength: ASTCount *

IN/OUT The length of pInstanceID in bytes.

permIDLength: ASTCount *

IN/OUT The length of pPermaID in bytes.

Returns
ASBool

true if the ID is returned, false otherwise.

CosDocGetObjByID

CosProcs.h:1200

Gets the indirect CosObj with the latest generation number.

Parameters
dP: CosDoc

The CosDoc to search for the matching Cos object.

objNum: CosID

The local master index for the indirect Cos object to return.

Returns
CosObj

The CosObj with the latest generation number whose ID (object number) equals objNum , or the NULL object if there is no object with this ID.

See Also

CosDocGetRoot

CosProcs.h:967

Gets the Catalog (the root object) for the specified document. See the description of the Document Catalog in "Common Data Structures" in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 7.7.2, page 71. You can find this document on the web store of the International Standards Organization (ISO).

Parameters
dP: CosDoc

IN/OUT The document whose Catalog is obtained.

Returns
CosObj

The document's Catalog dictionary Cos object.

CosDocHasFullCompression

CosProcs.h:1798

Tests whether the Cos document is fully compressed. In a fully compressed document, most objects are stored in object streams, which are normally Flate-encoded to reduce the size of the PDF file. Cross-reference information for these objects is stored in cross-reference streams, which are also normally Flate-encoded. See the description of "Cross-Reference Streams" in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 7.5.8, page 49. You can find this document on the web store of the International Standards Organization (ISO).

Parameters
doc: CosDoc

The document whose compression is checked.

Returns
ASBool

true if the document is fully compressed, false otherwise.

CosDocHasISOExtensions

CosProcs.h:2420

Tests whether the supplied CosDoc contains the Adobe Extensions Dictionary for the ISO 32000 standard. When the Extensions Dictionary is added to a PDF document, it allows PDF features provided in Adobe Acrobat after PDF version 1.7 to be used with that document. The version of the PDF file is drawn from the Extensions Dictionary instead of from the file header. See https://www.adobe.com/devnet/pdf/pdf_reference.html When the Extensions Dictionary is added to a PDF document, it allows PDF features provided in Adobe Acrobat after PDF version 1.7 to be used with that document. The version of the PDF file is drawn from the Extensions Dictionary instead of from the file header. See https://www.adobe.com/devnet/pdf/pdf_reference.html

Parameters
dP: CosDoc

The Cos document to test.

Returns
ASBool

true if the file contains the Adobe Extensions dictionary for the ISO 32000 standard, false otherwise.

CosDocHasPartialCompression

CosProcs.h:1828

Tests whether the Cos document is partially compressed. In a partially compressed file, the size of the logical structure information is reduced. Current PDF viewers have full access to the structure information. In a partially compressed document, objects related to logical structure are stored in object streams, which are normally Flate-encoded to compress the document. Their cross-reference information is stored twice: in a cross-reference stream, to which there is a reference in the trailer of an update section, and in the main cross-reference table, which indicates that the objects are on the free list. See the description of "Cross-Reference Streams" in section 7.5.8 in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, page 49. You can find this document on the web store of the International Standards Organization (ISO). See also the decription of the "Cross-Reference Table" in section 7.5.3, page 40.

Parameters
doc: CosDoc

The document whose compression is checked.

Returns
ASBool

true if the document is partially compressed, false otherwise.

CosDocObjIsWithinRange

ASBool CosDocObjIsWithinRange(CosObj obj, ASInt32 byteRanges[], ASInt32 numEntries)
CosProcs.h:1577

Tests whether the definition of a specified Cos object, in the file associated with the object's CosDoc, begins within any of a set of byte ranges. The test is inclusive; that is the object may begin at the first or last byte of a range. An exception is raised if obj is a direct object or numEntries is an odd number.

Parameters
obj: CosObj

The Cos object (must be indirect).

byteRanges: ASInt32

An array containing pairs of byte offsets within the document. Each pair is a start and end offset from the beginning of the document.

numEntries: ASInt32

The number of byte offsets (not pairs) in the byteRanges array.

Returns
ASBool

true if the object begins within any of the given ranges and has not been modified, false otherwise.

CosDocObjIsWithinRange64

CosProcs.h:2263

Tests whether the definition of a specified Cos object, in the file associated with the object's CosDoc , begins within any of a set of byte ranges. For details, see CosDocObjIsWithinRange() . This is the same as CosDocObjIsWithinRange() , except that the byte ranges are 64-bit file positions instead of a 32-bit file positions. An exception is raised if obj is a direct object or numEntries is an odd number.

Parameters
obj: CosObj

The Cos object (must be indirect).

byteRanges: ASFilePos64

An array containing pairs of byte offsets within the document. Each pair is a start and end offset from the beginning of the document.

numEntries: ASInt32

The number of byte offsets (not pairs) in the byteRanges array.

Returns
ASBool

true if the object begins within any of the given ranges and has not been modified, false otherwise.

CosDocOpenWithParams

CosDoc CosDocOpenWithParams(CosDocOpenParams params)
CosProcs.h:1064

Opens a Cos document. The document does not need to be a PDF document. In params , the client specifies a file system and path name from which to open the document. The client may also specify a header string other than "%PDF-" . For example, a client might want to open a private file type, such as "%FDF-" . Various exceptions may be raised. Opening non-Cos docs with this API is unsupported and may lock the file after an open attempt. If the doRepair flag is set in the open flags, a minimal document can be opened. A minimal document contains the header string and a trailer dictionary. It may contain indirect objects before the trailer dictionary, and the trailer dictionary can refer to those objects, as shown in the following example: FDF-1.0 1 0 obj << /Version /1.5 /FDF << /F 20 0 R /JavaScript 5 0 R >> >> trailer << /Root 1 0 R >>

Parameters
params: CosDocOpenParams

Specifies how to open the document.

Returns
CosDoc

A Cos document.

See Also

CosDocSaveToFile

void CosDocSaveToFile(CosDoc cosDoc, ASFile asFile, CosDocSaveFlags saveFlags, CosDocSaveParams saveParams)
CosProcs.h:1131

Saves a Cos document to a file handle. CosDocSaveToFile() will not generate an cross-reference table in the saved file. If you want the cross-reference to be generated, then you have to use CosDocSaveWithParams() , which generates the cross-reference table by default. Saves a Cos document to a file. CosDocSaveToFile() will not generate a cross-reference index (table or stream) in the saved file. If you want the index to be generated, then you must use CosDocSaveWithParams() , which generates it by default.

Parameters
cosDoc: CosDoc

The document to save.

asFile: ASFile

The file to which the document is written; it must be open in write mode. This file is not necessarily position-able.

saveFlags: CosDocSaveFlags

An OR of the CosDocSaveFlags bit flag values specifying how to save the document.

saveParams: CosDocSaveParams

Optional parameters for use when saving a document, as described in CosDocSaveParams() .

Returns
void
Since
Saves a Cos document to a file. CosDocSaveToFile() will not generate a cross-reference index (table or stream) in the saved file. If you want the index to be generated, then you must use CosDocSaveWithParams() , which generates it by default.

CosDocSaveWithParams

void CosDocSaveWithParams(CosDoc cosDoc, ASFile asFile, CosDocSaveFlags saveFlags, CosDocSaveParams saveParams)
CosProcs.h:1245

Saves a Cos document, optionally to a new file handle. It generates an cross-reference table by default. Saves a Cos document, optionally to a new file. It generates a cross-reference index (table or stream) by default.

Parameters
cosDoc: CosDoc

The CosDoc for the document to save.

asFile: ASFile

The file to which the document will be written. This file must already be open in write mode. If you pass NULL , cosDoc is saved to the file with which it was originally associated.

saveFlags: CosDocSaveFlags

An OR of the CosDocSaveFlags bit flag values specifying how to save the document.

saveParams: CosDocSaveParams

CosDocSaveParams parameters for use when saving the CosDoc document.

Returns
void
Since
Saves a Cos document, optionally to a new file. It generates a cross-reference index (table or stream) by default.

CosDocSetAdobeExtensionLevel

void CosDocSetAdobeExtensionLevel(CosDoc dP, CosObj baseVersion, ASUns32 extension)
CosProcs.h:2460

Adds the necessary data structures to the supplied CosDoc to identify it as containing the Adobe Extensions Dictionary for the ISO 32000 standard. When the Extensions Dictionary is added to a PDF document, it allows PDF features provided in Adobe Acrobat after PDF version 1.7 to be used with that document. The version of the PDF file is drawn from the Extensions Dictionary instead of from the file header. See https://www.adobe.com/devnet/pdf/pdf_reference.html

Parameters
dP: CosDoc

The Cos document to set.

baseVersion: CosObj

The PDF version on which the extensions are based (will be of type CosName ).

extension: ASUns32

The level of the extension expressed as a monotonically increasing integer.

Returns
void

CosSetMaxDocStorage

CosProcs.h:1553

Puts a limit on the amount of memory (RAM) that can be used to store Cos objects per doc. The default, minimum and maximum values of this limit are 30 MB, 512 KB and 40 MB respectively. This method can be used to increase or decrease the amount of memory reserved for Cos objects within this limit. Beyond the limit, Cos objects may be stored on disk.

Parameters
maxMemory: ASInt32

The maximum amount of RAM (in bytes) that will be used to store fixed-size Cos objects.

Returns
void

Typedefs(4)

CosDocEnumEOFsProc

typedef ASBool(* CosDocEnumEOFsProc) (CosDoc cosDoc, ASFileOffset fileOffset, void *clientData))(CosDoc cosDoc, ASFileOffset fileOffset, void *clientData)
CosExpT.h:273

A callback for CosDocEnumEOFs(). It is called once for each position in a CosDoc after a %EOF keyword that marks the end of either a main cross-reference section, or an update cross-reference section that corresponds to an incremental save. See CosDocEnumEOFs() for more details. The precise value passed to the procedure is not defined. It is at least one byte past the %EOF keyword, but may include one or more white space characters. When the procedure is called only once, there is no guarantee that fileOffset is the same as the length of the file.

CosDocEnumEOFsProc64

typedef ASBool(* CosDocEnumEOFsProc64) (CosDoc cosDoc, ASFileOffset64 fileOffset, void *clientData))(CosDoc cosDoc, ASFileOffset64 fileOffset, void *clientData)
CosExpT.h:292

A callback for CosDocEnumEOFs64(). It is called once for each position in a CosDoc after a %EOF keyword that marks the end of either a main cross-reference section, or an update cross-reference section that corresponds to an incremental save. See CosDocEnumEOFs() for more details. This is similar to CosDocEnumEOFsProc(), except that the fileOffset parameter is a 64-bit value instead of a 31-bit value.

Structures(1)

Definitions(7)

cosSaveBinaryOK

CosExpT.h:208
Value:0x08

It is ok to store binary data in the file.

cosSaveConcealObjStreams

CosExpT.h:213
Value:0x10

If there are any object streams, write them in a way that is hidden from PDF 1.4 (and earlier) viewers. This is used for hybrid files, for example.

cosSaveCopy

CosExpT.h:206
Value:0x04

Do NOT use the newly saved file as new store, stay with the current one

CosName

4 items

Functions(4)

CosCopyNameStringValue

CosProcs.h:2190

Returns a newly allocated buffer containing a copy of the Cos object's name as a NULL -terminated string. Upon return, nBytes contains the number of bytes in the string. CosCopyNameStringValue() never returns NULL ; it raises an exception if the allocation fails. The client is responsible for freeing the result by calling ASfree() . Unlike Cos strings, the strings corresponding to Cos names are NULL -terminated. This routine will avoid creating an ASAtom corresponding to the object's name and is generally more efficient than copying the value returned by ASAtomGetString(CosNameValue(obj)) . ( ASAtom objects consume global memory that is not deallocated.) An out-of-memory exception is raised if insufficient memory is available.

Parameters
obj: CosObj

IN A Cos name object.

nBytes: ASTCount *

OUT The length of the name of the Cos object, and therefore the length of the returned string. nBytes may be NULL if you do not care how many bytes are in the name.

Returns
char *

A copy of the Cos object's name, as a NULL -terminated string.

CosNameValue

CosProcs.h:547

Gets the value of a name object. An exception is raised if obj has the wrong type, if storage is exhausted, or if file access fails.

Parameters
obj: CosObj

The object of type CosName whose value is obtained.

Returns
ASAtom

The ASAtom corresponding to the specified name object. An ASAtom can be converted to a string using ASAtomGetString() . Note that CosCopyNameStringValue() can be used to obtain the name as a string, without creating an ASAtom ( ASAtom objects consume global memory that is not deallocated).

CosNewName

CosObj CosNewName(CosDoc dP, ASBool indirect, ASAtom name)
CosProcs.h:215

Creates a new name object associated with the specified document and having the specified value.

Parameters
dP: CosDoc

The document in which the new name is used.

indirect: ASBool

If true , it creates the name as an indirect object, and sets the document's PDDocNeedsSave flag (see PDDocFlags ) flag. If false , it creates the name as a direct object.

name: ASAtom

The ASAtom corresponding to the name to create. A C string can be converted to an ASAtom using ASAtomFromString() . Note that a name object can be created directly from a C string, without creating an ASAtom , by using CosNewNameFromString() .

Returns
CosObj

The newly created name Cos object.

CosNewNameFromString

CosObj CosNewNameFromString(CosDoc dP, ASBool indirect, const char *namestring)
CosProcs.h:2159

Creates a new name object associated with the specified document and having the specified value.

Parameters
dP: CosDoc

The document in which the new name is used.

indirect: ASBool

If true , it creates the name as an indirect object, and sets the document's PDDocNeedsSave flag (see PDDocFlags ) flag. If false , it creates the name as a direct object.

namestring: const char *

The name to create. This routine will not create an ASAtom corresponding to namestring and is generally more efficient than CosNewName() . ( ASAtom objects consume global memory that is not deallocated.)

Returns
CosObj

The newly created name Cos object.

CosNumber

13 items

Functions(13)

CosIntegerValue

CosProcs.h:504

Gets the 32-bit integer value of a specified number object. An exception is raised if the given object has the wrong Cos type.

Parameters
obj: CosObj

The object whose integer value is obtained. It must have type CosInteger or CosReal ( CosFixed ). If it is CosReal , its value is rounded to the nearest integer. The result is undefined if the real value is outside the range of ASInt32 numbers.

Returns
ASInt32

The 32-bit integer value of obj .

CosNewDoubleEx

CosObj CosNewDoubleEx(CosDoc dP, ASBool indirect, double value, ASUns8 numSigDigs)
CosProcs.h:2382

Creates a new real-number object from a double-precision floating-point number associated with the specified document.

Parameters
dP: CosDoc
indirect: ASBool
value: double

The maximum number of significant digits to use when this object is written to a file. Legal values are 6-13 for direct objects, 6-16 for indirect objects

numSigDigs: ASUns8
Returns
CosObj

A Cos object of type CosReal ( CosFixed ).

CosNewInteger64

CosProcs.h:1850

Acrobat 7 additions Creates a new 64-bit integer object associated with the specified document and having the specified value.

Parameters
dP: CosDoc

IN The document in which the integer is used.

indirect: ASBool

IN If true , it creates the integer object as an indirect object, and sets the document dP object's PDDocNeedsSave flag (see PDDocFlags). If false , it creates the integer as a direct object.

value: ASInt64

IN The value, represented as a 64-bit integer.

Returns
CosObj

An object of type CosInteger.

CosNumberIsWithinASFixedRange

CosProcs.h:2242

Tests whether the value of a Cos number is inside the range of ASFixed numbers, [-32768.0, +32768.0) . If so, the ASFixed value may be obtained by calling CosFixedValue(). If not, the floating-point value may be obtained by calling CosFloatValue(). It raises an exception if obj is not a number ( CosInteger or CosReal ).

Parameters
obj: CosObj

A Cos integer or real number.

Returns
ASBool

true if the value of the number is in the range of ASFixed , false otherwise.

CosNumberIsWithinASInt32Range

CosProcs.h:2226

Tests whether the value of a Cos number is inside the range of 32-bit integers, [-2147483648, +2147483647] . If so, the 32-bit value may be obtained by calling CosIntegerValue() . If not, the 64-bit value may be obtained by calling CosIntegerValue64() . It raises an exception if obj is not a number ( CosInteger or CosReal ).

Parameters
obj: CosObj

A Cos integer or real number.

Returns
ASBool

true if the value of the number is in the range of 32-bit integers, false otherwise.

CosObj

27 items

Functions(18)

CosNewNull

CosProcs.h:141

Returns a direct object of type CosNull. This NULL object is said to be invalid. You can compare an object to NULL using either of the following methods (the second is more efficient): CosObjEqual(obj, CosNewNull()); CosObjGetType(obj) == CosNull; In general, use CosNewNull() only to initialize a local variable or pass a parameter. NULL objects may be stored as array elements, but not as dictionary values. The following statements are equivalent: CosDictPut(dict, key, CosNewNull()); CosDictRemove(dict, key);

Parameters
: void
Returns
CosObj

A NULL Cos object.

See Also

CosObjAcquire

CosProcs.h:2124

Create a strong reference for an object. For a description of strong references, see CosDictSetWeakReference() . For indirect objects and direct nonscalars, CosObjAcquire() increments an internal reference count for obj . The reference count is used by the garbage collector, which is invoked during a full-save of the document. If the reference count is positive at the time of garbage collection (it is initially 0 ), then the object will not be garbage-collected, regardless of whether the object is accessible from the root of the document.

Parameters
obj: CosObj

A Cos object.

Returns
void

CosObjCmp

CosProcs.h:1541

Compares the two CosObj objects. The result is 0 only if CosObjEqual(obj1, obj2) is true . Otherwise, the result is either -1 or 1 . The result is useful for ordering or sorting Cos objects. No other significance should be attached to the result. In particular, a nonzero result indicates nothing about the type of either object. The result is valid only within a single instance of the document. That is, if CosObjCmp() returns a nonzero value and the document is closed and then reopened, there is no guarantee that it will return the same nonzero value for those same objects. The following conditions apply: If CosObjCmp(a, b) == 0 , then CosObjCmp(b, a) == 0 . If CosObjCmp(a, b) > 0 , then CosObjCmp(b, a) < 0 . If CosObjCmp(a, b) < 0 , then CosObjCmp(b, a) > 0 . If CosObjCmp(a, b) == 0 and CosObjCmp(b, c) == 0 , then CosObjCmp ( a, c ) == 0 . If CosObjCmp(a, b) > 0 and CosObjCmp(b, c) > 0 , then CosObjCmp (a, c) > 0 . If CosObjCmp(a, b) < 0 and CosObjCmp(b, c) < 0 , then CosObjCmp(a, c) < 0 .

Parameters
obj1: CosObj

The first CosObj to compare.

obj2: CosObj

The second CosObj to compare.

Returns
ASInt32

Returns zero if the two objects are equal, -1 if obj1 is less than obj2 , 1 if obj1 is greater than obj2 .

See Also

CosObjCopy

CosObj CosObjCopy(CosObj srcObj, CosDoc destDoc, ASBool copyIndirect)
CosProcs.h:1330

Copies a CosObj from one document to another (or the same document).

Parameters
srcObj: CosObj

The CosObj to copy.

destDoc: CosDoc

The CosDoc for the document into which the CosObj is copied.

copyIndirect: ASBool

true if all indirectly referenced objects from srcObj are copied to destDoc , false otherwise.

Returns
CosObj

The CosObj which has been copied to the destination document.

See Also

CosObjEnum

ASBool CosObjEnum(CosObj obj, CosObjEnumProc proc, void *clientData)
CosProcs.h:106

Enumerates the elements of a Cos object by calling a user-supplied procedure for each component of the object.

Parameters
obj: CosObj
proc: CosObjEnumProc

A user-supplied callback to call for each element of obj . Neither proc nor any routine called by proc may modify obj . Doing so can produce undefined results or errors. For example, if obj is an array, proc must not call CosArrayRemove(); if obj is a dictionary, proc must not call CosDictPut().

clientData: void *

A pointer to user-supplied data to pass to proc each time it is called.

Returns
ASBool

Returns true if every call to proc returned true . As soon as any call to proc returns false , the enumeration stops and CosObjEnum() returns false .

CosObjEqual

CosProcs.h:55

Tests whether two Cos objects are equal. Cos objects are equal when all of the following conditions are true: They are either both direct or both indirect. They have the same type. If they are indirect, they have the same generation number. If they are scalars, they have the same value. (Two NULL objects are equal.) If they are non-scalar, they reference the same value. The last condition implies that the comparison is shallow . For example: CosObj a, b, c; a = CosNewString (doc, "XYZ"); b = CosNewString(doc, "XYZ"); c = b; In this case, CosObjEqual(a,b) is false , but CosObjEqual(b,c) is true .

Parameters
obj1: CosObj

An object to compare with obj2 .

obj2: CosObj

An object to compare with obj1 .

Returns
ASBool

true if obj1 and obj2 are equal, false otherwise.

See Also

CosObjGetCompressibility

CosProcs.h:1706

Tests whether an object is compressible . A compressible object can be added to a CosObjCollection . An object is compressible only if all of the following conditions are true: It is indirect. It has a generation number of zero. It is not a stream. It has not been marked as incompressible by CosObjSetCompressibility() .

Parameters
obj: CosObj

The object to test.

Returns
ASBool

true if obj is compressible, false otherwise.

CosObjGetGeneration

CosProcs.h:1185

Gets the generation number of an indirect Cos object. See the description of the Indirect Objects in "Objects," in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 7.3.1, page 21. You can find this document on the web store of the International Standards Organization (ISO).

Parameters
obj: CosObj

IN/OUT The indirect CosObj for which the generation number is obtained. A CosObj can be determined to be indirect using CosObjIsIndirect() .

Returns
CosGeneration

The generation number of cosObj .

CosObjHash

CosProcs.h:1315

Gets a 32-bit hash code for the given CosObj . Two CosObj objects with equal hash codes are not necessarily equal, however. Use CosObjEqual() to determine the equality of Cos objects.

Parameters
obj: CosObj

The CosObj for which to obtain a hash code.

Returns
CosHashCode

32-bit hash code for the given CosObj , or CosNewNull() if there is no object with this ID.

See Also

CosObjRefreshAfterLinearizedSave

CosProcs.h:1776

In Acrobat 6.0, this method updates an indirect Cos object after a linearized save operation. Linearizing renumbers all indirect objects; this function returns the new renumbered Cos object, which should be used from this point on. This call is only valid from within notification callbacks responding to the PDDocDidSave() notification. If called from outside this context, or if the passed Cos object is direct, the function does not modify the object. In Acrobat 7.0 and later, linearizing does not renumber objects, and this method has no effect.

Parameters
obj: CosObj *

A pointer to the object to refresh. The object is updated by the method.

doc: CosDoc

The document that was saved.

Returns
void

CosObjRelease

CosProcs.h:2138

Removes a strong reference for an object. For a description of strong references, see CosDictSetWeakReference() . For indirect objects and direct nonscalars, CosObjRelease() decrements an internal reference count for obj . The reference count is used by the garbage collector, which is invoked during a full-save of the document. If the reference count is positive at the time of garbage collection (it is initially 0 ), then the object will not be garbage-collected, regardless of whether the object is accessible from the root of the document.

Parameters
obj: CosObj

A Cos object.

Returns
void

CosObjSetCompressibility

void CosObjSetCompressibility(CosObj obj, ASBool compressible)
CosProcs.h:1686

Controls whether a Cos object can be compressed. A compressible object can be added to a CosObjCollection. If you set the compressibility to false , calling CosObjAddToCollection() on that object has no effect. If the object is already compressed, it is removed from the object collection to which it belongs and then marked as incompressible. This method does nothing if applied to a direct object, a stream, or an object whose generation number is not zero. Objects of these types are never compressible.

Parameters
obj: CosObj

The object whose compressibility is set.

compressible: ASBool

true if the object can be made part of a CosObjCollection , false otherwise.

Returns
void

true if obj is marked as compressible, false otherwise.

Typedefs(9)

CosObjEnumProc

typedef ASBool(* CosObjEnumProc) (CosObj obj, CosObj value, void *clientData))(CosObj obj, CosObj value, void *clientData)
CosExpT.h:132

A callback for CosObjEnum(), CosDocEnumIndirect(), and PDDocEnumOCGs(). It is called once for each component of a composite Cos object (dictionary, array, and stream). Value Description Dictionary A key. Array An array element. Stream The stream's dictionary (the whole thing, not one key at a time). Value Description Dictionary The value associated with the Key. Array A NULL Cos object. Stream A NULL Cos object. For CosDocEnumIndirect() and PDDocEnumOCGs(), this is always the NULL Cos object.

CosObjSetCallbackFlagProc

typedef ASBool(* CosObjSetCallbackFlagProc) (CosObj obj, ASBool set))(CosObj obj, ASBool set)
CosExpT.h:326

A callback in PDDocPreSaveInfo(), which is used by the PDDocPreSaveProc() callback. Use this callback to set a flag in each CosObj that you care about, so that your callback will be called back during the PDDoc's save and will be given the Cos object's offset and length. After a PDF file is saved, the Cos objects previously obtained are no longer valid.

CosObjCollection

9 items

Functions(8)

CosObjAddToCollection

CosProcs.h:1647

Adds a Cos object to a collection; see CosObjCollection for requirements of these collections. This method sets the dirty flag of the collection's Cos document. An exception is raised if the collection and the object belong to different Cos documents.

Parameters
coll: CosObjCollection

The Cos object collection.

item: CosObj

The object to add.

Returns
ASBool

true if obj was successfully added to the collection, false otherwise.

CosObjCollectionEnum

CosProcs.h:1756

Enumerates the members of a Cos object collection, calling a user-supplied procedure for each member object. The order in which the objects are enumerated is undefined.

Parameters
coll: CosObjCollection

The object collection whose members are enumerated.

proc: CosObjEnumProc

A user-supplied callback to call for each member object of coll . Enumeration ends if proc returns false . The callback must not modify the collection (for example, by adding or removing objects). Doing so produces undefined results or errors.

clientData: void *

A pointer to user-supplied data to pass to proc each time it is called.

Returns
ASBool

Returns the value that proc returned (meaning that it returns true if all the member objects were enumerated, false if enumeration was terminated at the request of proc ).

CosObjCollectionEqual

CosProcs.h:1735

Tests whether two Cos object collections are the same collection. Two NULL collections are always equal (a NULL collection is not associated with a document and cannot store objects; it is generally used only as an initial value for a variable of type CosObjCollection ).

Parameters
c1: CosObjCollection

An object collection to compare.

c2: CosObjCollection

An object collection to compare.

Returns
ASBool

true if c1 and c2 are the same collection, false otherwise.

Typedefs(1)

CosStream

11 items

Functions(8)

CosNewStream

CosObj CosNewStream(CosDoc dP, ASBool indirect, ASStm stm, CosStreamStartAndCode sourceStart, ASBool encodeTheSourceData, CosObj attributesDict, CosObj encodeParms, CosByteMax sourceLength)
CosProcs.h:465

Creates a new Cos stream, using data from an existing ASStm . The data is copied, so the source stream may be closed after CosNewStream returns. This method creates a Cos stream object by writing its PDF representation to an intermediate file in this format: <</Length ... /Filter ... /DecodeParms ...>> stream ... data, possibly encoded ... endstream See the description of the Stream Objects in "Objects," in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 7.3.8, page 19. You can find this document on the web store of the International Standards Organization (ISO). This occurs in four steps: Step 1: Writing the attribute dictionary If attributesDict is a valid Cos dictionary, the method writes that dictionary to the intermediate file. Otherwise, it creates a new direct dictionary, determining a Length key according to the sourceLength value: If sourceLength is negative, or if the source data is to be encoded (see below), the value of the Length key is a reference to a new indirect object, whose value will be set in Step 4 . Otherwise, Length is a direct scalar representing sourceLength . The dictionary that is written becomes the new stream's attribute dictionary. Step 2: Reading the data sourceStart determines where in the source stream to begin reading, and whether the source is seekable. If sourceStart is a negative number, the source is assumed to be non-seekable but positioned at the point where reading should start. Otherwise, the source is assumed to be seekable, and reading starts at the position indicated by sourceStart . If sourceStart is zero, data is read from the beginning of the source stream. Positive values for sourceStart may be used, for instance, to skip over initial data in the stream. Step 3: Encoding the data If attributesDict is a valid Cos dictionary, it contains a Filter key, and encodeTheSourceData is true , the method encodes the data after reading it from the source stream and before writing it to the intermediate file. The attributesDict is used as the new stream's dictionary. The Filter entry in this dictionary indicates how the data in the resulting Cos stream object will be subsequently decoded; the value may be the name of a decoding filter or an array of such names. Specify multiple filters in the order they should be applied to decode the data (if parameters are needed to decode the data, they are specified as the value of the DecodeParms key in attributesDict . See the description of the DecodeParms attribute in Table 5 in ISO 32000-1:2008, Document Management-Portable Document Format- Part 1: PDF 1.7, section 7.3.8.2, page 20. You can find this document on the web store of the International Standards Organization (ISO). For each decoding filter, there is a corresponding encoding filter, which the method applies to the source data during this step. If parameters are needed to encode the data, they must be specified in the call by encodeParms (the encoding parameters are often different from the decoding parameters). The encodeParms parameter is optional for all encoding filters except DCTDecode and JBIG2Decode . See the encodeParms field of . If an array of filters is supplied, and at least one of them requires encoding parameters, then a corresponding array of encoding parameters is also required. Use the NULL object to represent default parameters for filters that have defaults. In any other case, the method copies the source data directly into the Cos stream with no encoding. If sourceLength is negative, it reads bytes until the source reaches its EOF. Otherwise, sourceLength indicates how many bytes to read from the source, and an exception is raised if the source reaches EOF before that. Step 4: Writing the data After the data is written, if the value of the Length key in the attributes dictionary was an indirect reference (either because it was supplied that way in attributesDict , or because it was created that way in Step 1 , the value of that indirect object is set to the number of bytes actually written (that is, the encoded length if the data was encoded). An indirect Length key is useful for one-pass writing, when the size of the written data is not known in advance, either because the data was to be encoded, or because there was no way to know how much data there would be before the source reached its EOF. An exception is raised if attributesDict is neither the NULL object nor a direct Cos dictionary, sourceStart is nonnegative but the source is not seekable, or if sourceLength is nonnegative but the source stream reaches EOF before that many bytes have been read. For attributeDict, see the description of Stream Objects in the ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 9.9, page 288. You can find this document on the web store of the International Standards Organization (ISO). See the encoding step in the description above. You can find this document on the web store of the International Standards Organization (ISO). See the encoding step in the description above. If no encoding parameters are needed, this value is ignored. CosNewStream() sets the document PDDocNeedsSave flag (see PDDocFlags). You cannot call CosStreamPos() on a stream created with CosNewStream() until the file has been saved.

Parameters
dP: CosDoc

The Cos document in which the newly created stream will be used.

indirect: ASBool

Must always be true , specifying that the Cos stream is created as an indirect object (all streams are indirect). This also sets the document's PDDocNeedsSave flag (see PDDocFlags ).

stm: ASStm

The source stream containing the data to copy into the new stream. The caller is responsible for closing stm after CosNewStream() returns. The source stream can be any readable ASStm . Typical sources are:

Files ( ASFileStmRdOpen() ) or memory ( ASMemStmRdOpen() ). These streams are always seekable.

Arbitrary procedures ( ASProcStmRdOpen() or ASProcStmRdOpenEx() ), or other Cos streams ( CosStreamOpenStm() ). These streams are always non-seekable.

sourceStart: CosStreamStartAndCode

The byte offset into stm from which data reading starts for a seekable stream. If the value is negative, it specifies that the stream is not seekable.

encodeTheSourceData: ASBool

Determines whether the data in stm should be encoded using filters specified in attributesDict before it is written to the Cos stream. See the description of the encoding step above. If attributesDict is a NULL object or if the dictionary has no Filter key, this value is ignored.

attributesDict: CosObj

Either the NULL Cos object, or a direct Cos dictionary containing stream attributes, such as the length of the Cos stream data and a list of decoding filters and parameters to apply to the data. See the description of the Stream Objects in "Objects" in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 7.3.8, page 19.

encodeParms: CosObj

The parameters to be used by the filters if the source data is encoded before it is written to the file. The parameters follow the structure for the value of the DecodeParms stream attribute. See the description of the DecodeParms attribute in Table 5 in ISO 32000-1:2008, Document Management-Portable Document Format-Part 1: PDF 1.7, section 7.3.8.2, page 20.

sourceLength: CosByteMax

The amount of data to be read from the source. If negative (typically -1 ), data is read from the source until it reaches its EOF. See Step 1 in the description above.

Returns
CosObj

The newly created stream Cos object.

CosNewStream64

CosObj CosNewStream64(CosDoc dP, ASBool indirect, ASStm stm, ASInt64 stmStartPos, ASBool stmDataIsDecoded, CosObj attributesDict, CosObj encodeParms, ASInt64 sourceLength, ASBool allowDelayedRead)
CosProcs.h:2302

Creates a new Cos stream, using data from an existing ASStm . For details, see CosNewStream() . This is the same as CosNewStream() , except that decodeLength is a 64-bit value instead of a 32-bit value, and allowDelayedRead enables the implementation to avoid making an intermediate copy of the stream data. This is useful when creating very large streams of data. Important: In this case, the caller must not close stm until it is established, through some independent mechanism, that the data will not be read again (see ASProcStmRdOpenEx() for further details on this feature). If allowDelayedRead is false , the source data is copied during this call, so the source stream may be closed after CosNewStream64() returns.

Parameters
dP: CosDoc

The Cos document in which the newly created stream will be used.

indirect: ASBool

Must always be true , specifying that the Cos stream is created as an indirect object.

stm: ASStm

The source stream containing the data to copy into the new stream.

stmStartPos: ASInt64

Starting position for the stream. Its default is 0 .

stmDataIsDecoded: ASBool

A boolean value indicating whether the data in stm should be encoded using filters specified in attributesDict .

attributesDict: CosObj

Either the NULL Cos object, or a direct Cos dictionary containing stream attributes.

encodeParms: CosObj

The parameters to be used by the filters if the source data is to be encoded.

sourceLength: ASInt64

The amount of data to be read from the source.

allowDelayedRead: ASBool

If this is true and stm permits seek operations, then the data from stm will not be read during this call, but rather at a subsequent time, and it may be read more than once.

Returns
CosObj

The newly created stream Cos object.

CosStreamLength

CosProcs.h:896

Gets the length of a Cos stream from the Length key in the stream's attributes dictionary. This specifies the length of the undecoded data, which is the number of bytes in the stream before the Filter (if any) is applied. This has the same effect as calling CosIntegerValue(CosDictGetKeyString(stream, "Length")) . An exception is raised if the Length key is not found in the attributes dictionary, if its value is not an integer, or if its value is outside the range of 32-bit integers.

Parameters
stream: CosObj

The stream whose length is obtained.

Returns
ASTArraySize

The length of the stream.

CosStreamLength64

CosProcs.h:2322

Gets the length of a Cos stream from the Length key in the stream's attributes dictionary. See CosStreamLength() for details. This is the same as CosStreamLength() , except that the return value is a 64-bit integer instead of a 32-bit integer. This has the same effect as calling CosInteger64Value(CosDictGetKeyString(stream, "Length")) An exception is raised if the Length key is not found in the attributes dictionary, or if its value is not an integer.

Parameters
stream: CosObj

The stream whose length is obtained.

Returns
ASInt64

The length of the stream.

CosStreamOpenStm

CosProcs.h:926

Creates a new, non-seekable ASStm for reading data from a Cos stream. The data in the Cos stream may be filtered and encrypted. After opening the Cos stream, data can be read from it into memory using ASStmRead() . When reading is completed, close the stream using ASStmClose() .

Parameters
stream: CosObj

The Cos stream object for which an ASStm is opened.

mode: CosStreamOpenMode

This must be one of the CosStreamOpenMode values.

Returns
ASStm

The newly-opened ASStm .

CosStreamPos

CosProcs.h:953

Gets the byte offset of the start of a Cos stream's data in the PDF file (which is the byte offset of the beginning of the line following the stream token). Use this method to obtain the file location of any private data in a stream that you need to read directly rather than letting it pass through the normal Cos mechanisms. For example, this could apply to a QuickTime video embedded in a PDF file.

CosStreamPos() is only valid when called on a stream that is already stored in a PDF document. If the stream was created using CosNewStream(), the new stream is stored in the document's temp file, and you cannot invoke CosStreamPos() on it. After the file has been saved, you can use CosStreamPos() on the stream.

Parameters
stream: CosObj
Returns

CosStreamPos64

CosProcs.h:2338

Gets the byte offset of the start of a Cos stream's data in the PDF file. For details, see CosStreamPos() . This is the same as CosStreamPos() , except that the return value is a 64-bit file position instead of a 32-bit file position.

Parameters
stream: CosObj

The stream whose current position is obtained.

Returns
ASFilePos64

The byte offset of the start of the Cos stream's data in the PDF file.

Typedefs(3)

CosString

6 items

Functions(6)

CosCopyStringValue

char * CosCopyStringValue(CosObj obj, ASTCount *nBytes)
CosProcs.h:1459

Returns a newly allocated buffer containing a copy of the Cos object's string value. Upon return, nBytes contains the number of bytes in the original Cos string. CosCopyStringValue() never returns NULL; it raises an exception if the allocation fails. The client is responsible for freeing the result by calling ASfree().

CosCopyStringValue() allocates extra memory past the end of the string and writes zeros into these extra bytes to ensure that the string is NULL-terminated whether viewed as a UTF-16 (Unicode) string or as a C string (these bytes are not included in the number returned in nBytes). If the Cos string has 0 length, nBytes will be 0, and a pointer to newly allocated memory containing some zero bytes is returned (that is, CosCopyStringValue() still returns a NULL -terminated string but with zero length).

An out-of-memory exception is raised if insufficient memory is available. It can also raise any exception that CosStringValue() can raise.

@note In general, the returned value is not a NULL-terminated C string. Cos string objects are binary and can contain arbitrary byte sequences, including NULL characters. Standard C string handling functions may not work as expected.

Parameters
obj: CosObj
nBytes: ASTCount *
Returns
char *

CosStringValue

char * CosStringValue(CosObj obj, ASTCount *nBytes)
CosProcs.h:586

Gets the value of a string Cos object, and the string's length. An exception is raised if the type of obj is not a CosString . The pointer returned from this method is not guaranteed to remain valid if CosStringValue() is called again. It is recommended that you use CosStringValueSafe() or CosCopyStringValue() instead; these methods place the string into a user-allocated buffer. The caller must immediately copy the returned string. The memory pointed to be the return value may become invalid if any memory-allocating calls are made. In particular, consider the sequence:

str1 = CosStringValue(...);

str2 = CosStringValue(...);

In this case, the contents of str1 may be invalid by the time the second CosStringValue() call returns. The returned value is not a C-style string. Cos string objects can contain NULL bytes. Standard C string-handling functions may not work as expected.

Parameters
obj: CosObj

IN The object whose value is obtained.

nBytes: ASTCount *

OUT (Filled by the method) The length of the string, in bytes. It must be a non- NULL pointer.

Returns
char *

The value of obj .

CosStringValueSafe

char * CosStringValueSafe(CosObj obj, char *buffer, ASTArraySize bufferSize, ASTCount *nBytes)
CosProcs.h:1488

Copies at most bufferSize bytes from the obj parameter's string value into buffer , and stores the actual length of the Cos string in *nBytes . If bufferSize is greater than the length of the Cos string, the remaining bytes in buffer have undefined values upon return. A bad-parameter exception is raised if bufferSize is less than 0 or nBytes is NULL . It can also raise any exception that CosStringValue() can raise. In general, the returned value is not a NULL -terminated C string. Cos string objects are binary data and can contain any arbitrary byte sequence, including embedded NULL characters. Standard C string handling functions may not work as expected.

Parameters
obj: CosObj

The Cos object whose string value is copied.

buffer: char *

The buffer into which the Cos string value is copied, or NULL .

bufferSize: ASTArraySize

The length of buffer or 0 .

nBytes: ASTCount *

(Filled by the method) The length of the original Cos string in bytes (which may be more than bufferSize ). It must be a non- NULL pointer.

Returns
char *

A copy of the Cos string value or an exception. It will never return NULL .

PDDoc

1 items

Enums(1)

AdobePDFVersion

CosExpT.h:339
Values
kNullPDFVersion
—
kMinPDFVersion
—
kAdobeAcrobat4Version
—
kAdobeAcrobat5Version
—
kAdobeAcrobat6Version
—
kAdobeAcrobat7Version
—
kAdobeAcrobat8Version
—
kAdobeAcrobat9Version
—
kAdobeAcrobat9_1Version
—
kAdobeAcrobat10Version
—
kAdobeAcrobat11Version
—
kMinSaveVersion
—
kMinXRefStreamVersion
—
kDefaultPDFVersion
—
kLastAdobe1XVersionWithoutExt
—
kLastAdobe1XVersionWithExt
—
kMinPDFNextVersion
—
kCurrentPDFVersion
—