CosArrayGet
CosObj CosArrayGet(CosObj array, ASTArraySize index)Gets the specified element from an array.
Parameters
array: CosObjindex: ASTArraySize
9 items
CosObj CosArrayGet(CosObj array, ASTArraySize index)Gets the specified element from an array.
array: CosObjindex: ASTArraySizevoid CosArrayInsert(CosObj array, ASTArraySize pos, CosObj obj)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).
array: CosObjThe array into which the object is inserted.
pos: ASTArraySizeThe 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: CosObjThe object to insert.
voidASBool CosArrayIsWeakReference(CosObj array, ASInt32 n)Return the state of a weak reference in an array. See CosDictIsWeakReference() for details.
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.
ASTArraySize CosArrayLength(CosObj array)Gets the number of elements in array .
array: CosObjIN/OUT The array for which the number of elements is determined.
The number of elements in array .
void CosArrayPut(CosObj array, ASTArraySize index, CosObj obj)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.
array: CosObjThe array in which obj is stored.
index: ASTArraySizeThe location in array to store obj . The first element of an array has an index of zero.
obj: CosObjThe Cos object to insert into array .
voidvoid CosArrayRemove(CosObj array, CosObj obj)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).
voidvoid CosArrayRemoveNth(CosObj array, ASTArraySize pos)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 .
array: CosObjIN/OUT The CosArray from which to remove the member.
pos: ASTArraySizeIN/OUT The index for the array member to remove. Array indices start at 0 .
voidvoid CosArraySetWeakReference(CosObj array, ASInt32 n, ASBool isWeak)Establishes or removes a weak reference from an array. For a description of weak references, see CosDictSetWeakReference() .
array: CosObjAn array.
n: ASInt32The 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: ASBoolSets a weak reference for an array.
voidCosObj CosNewArray(CosDoc dP, ASBool indirect, ASTArraySize nElements)Creates and returns a new array Cos object.
dP: CosDocThe document in which the array is used.
indirect: ASBoolIf 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: ASTArraySizeThe number of elements that will be in the array. nElements is only a hint; Cos arrays grow dynamically as needed.
The newly created array Cos object.
2 items
ASBool CosBooleanValue(CosObj obj)Gets the value of the specified boolean object. An exception is raised if obj has the wrong Cos type.
obj: CosObjThe boolean Cos object whose value is obtained.
The value of obj .
CosObj CosNewBoolean(CosDoc dP, ASBool indirect, ASBool value)Creates a new boolean object associated with the specified document and having the specified value.
dP: CosDocIN The document in which the boolean is used.
indirect: ASBoolIN 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: ASBoolIN The value the new boolean object will have.
A Cos boolean object.
7 items
Gets the current version number of the encryption algorithm supported.
The current version number of the encryption supported.
void CosDecryptData(void *src, ASTArraySize len, void *dst, char *cryptData, ASTArraySize cryptDataLen)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.
src: void *The buffer containing the data to decrypt.
len: ASTArraySizeThe 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: ASTArraySizeThe length of the encryption key in bytes. It cannot be greater than 5 .
voidCosByteMax CosDecryptGetMaxKeyBytes(ASTVersion cryptVersion)Gets the maximum number of the decryption key length, in bytes, for the specified cryptVersion.
cryptVersion: ASTVersionThe maximum number of key length, in bytes, for the specified cryptVersion . If cryptVersion is not currently supported, it returns -1 .
void CosEncryptData(void *src, ASTArraySize len, void *dst, char *cryptData, ASTArraySize cryptDataLen)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.
src: void *The buffer containing the data to encrypt.
len: ASTArraySizeThe 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: ASTArraySizeLength of the encryption key, in bytes. It cannot be greater than 5 .
voidCosByteMax CosEncryptGetMaxKeyBytes(ASTVersion cryptVersion)Gets the maximum number of the encryption key length, in bytes, for the specified cryptVersion.
cryptVersion: ASTVersionThe maximum number of key length, in bytes, for the specified cryptVersion . If cryptVersion is not currently supported, it returns -1 .
typedef ASInt32(* CosCryptStringProc) (CosDoc dP, ASAtom filterName, char *dest, char *src, ASInt32 dstSize, ASInt32 srcLength, ASUns32 genNumber, ASUns32 objNumber))(CosDoc dP, ASAtom filterName, char *dest, char *src, ASInt32 dstSize, ASInt32 srcLength, ASUns32 genNumber, ASUns32 objNumber)A prototype for the string encryption/decryption callback. This is part of the Crypt Filter mechanism.
15 items
CosObj CosDictGet(CosObj dict, ASAtom key)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.
CosObj CosDictGetKey(CosObj dict, CosObj key)Gets the value of the specified key in the specified dictionary. For more details, see CosDictGet() .
The object associated with the specified key. If key is not present, it returns a NULL Cos object.
CosObj CosDictGetKeyString(CosObj dict, const char *key)Gets the value of the specified key in the specified dictionary. For more details, see CosDictGet() .
dict: CosObjThe dictionary or stream from which a value is obtained.
key: const char *The key whose value is obtained, represented as a string.
The object associated with the specified key. If key is not present, returns a NULL Cos object.
ASBool CosDictIsWeakReference(CosObj dict, const char *key)Gets the state of a weak reference. For details, see CosDictSetWeakReference() .
dict: CosObjA dictionary.
key: const char *The name of a key.
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.
ASBool CosDictKnown(CosObj dict, ASAtom key)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.
true if the value of a key is known (exists and is not NULL ) in dict , false otherwise.
ASBool CosDictKnownKey(CosObj dict, CosObj key)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().
true if the value of a key is known (exists and is not NULL ) in dict , false otherwise.
ASBool CosDictKnownKeyString(CosObj dict, const char *key)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() .
dict: CosObjThe dictionary or stream in which to look for key.
key: const char *The key to find, represented as a string.
true if the value of a key is known (exists and is not NULL ) in dict , false otherwise.
void CosDictPut(CosObj dict, ASAtom key, CosObj val)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.
voidvoid CosDictPutKey(CosObj dict, CosObj key, CosObj val)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.
voidvoid CosDictPutKeyString(CosObj dict, const char *key, CosObj val)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.
voidvoid CosDictRemove(CosObj dict, ASAtom key)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.
voidvoid CosDictRemoveKey(CosObj dict, CosObj key)Removes a key-value pair from a dictionary. For more details, see CosDictRemove() .
voidvoid CosDictRemoveKeyString(CosObj dict, const char *key)Removes a key-value pair from a dictionary. For more details, see CosDictRemove() .
dict: CosObjThe dictionary from which the key-value pair is removed.
key: const char *The key to remove, represented as a string.
voidvoid CosDictSetWeakReference(CosObj dict, const char *key, ASBool isWeak)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 .
dict: CosObjThe dictionary containing the weak reference.
key: const char *The name of a key in the dictionary.
isWeak: ASBoolIf 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.
voidCosObj CosNewDict(CosDoc dP, ASBool indirect, ASTArraySize nEntries)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).
dP: CosDocindirect: ASBoolnEntries: ASTArraySizeThe number of entries in the dictionary. This value is only a hint; Cos dictionaries grow dynamically as needed.
The newly created dictionary Cos object.
33 items
void CosDocClose(CosDoc cosDoc)Closes a Cos document. You should only call this method with a document obtained via CosDocOpenWithParams() to release resources used by the Cos document.
cosDoc: CosDocIN/OUT The document to close.
voidCosDoc CosDocCreate(ASFlagBits createFlags)Creates an empty Cos document.
createFlags: ASFlagBitsAn 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.
An empty Cos document.
ASBool CosDocEnumEOFs(CosDoc cosDoc, CosDocEnumEOFsProc proc, void *clientData)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.
cosDoc: CosDocproc: CosDocEnumEOFsProcclientData: void *ASBool CosDocEnumEOFs64(CosDoc cosDoc, CosDocEnumEOFsProc64 proc, void *clientData)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.
cosDoc: CosDocThe CosDoc in which the EOF's are enumerated.
proc: CosDocEnumEOFsProc64The CosDocEnumEOFsProc64() to call for each EOF.
clientData: void *A pointer to user-supplied data to pass to proc each time it is called.
true if all of the calls to proc return true , false as soon as a call to proc returns false .
ASBool CosDocEnumIndirect(CosDoc dP, CosObjEnumProc proc, void *clientData)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.
dP: CosDocThe CosDoc whose indirect objects are enumerated.
proc: CosObjEnumProcA 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.
true if all of the calls to proc returned true . It returns false as soon as a call to proc returns false .
ASBool CosDocGetAdobeExtensionLevel(CosDoc dP, CosObj *baseVersion, ASUns32 *extension)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
true if the file contains the Adobe Extensions dictionary for the ISO 32000 standard, false otherwise.
ASBool CosDocGetID(CosDoc dP, CosByte **pInstanceID, CosByte **pPermaID, ASTCount *instIDLength, ASTCount *permIDLength)Returns two ID byte arrays identifying the CosDoc. The client should copy these arrays before making the next call to Acrobat.
dP: CosDocIN/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.
true if the ID is returned, false otherwise.
Gets the specified document's Info dictionary. In general, access the document's Info dictionary using PDDocGetInfo() and PDDocSetInfo() wherever possible.
dP: CosDocIN/OUT The document whose Info dictionary is obtained.
The document's Info dictionary Cos object.
CosObj CosDocGetObjByID(CosDoc dP, CosID objNum)Gets the indirect CosObj with the latest generation number.
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.
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).
dP: CosDocIN/OUT The document whose Catalog is obtained.
The document's Catalog dictionary Cos object.
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).
doc: CosDocThe document whose compression is checked.
true if the document is fully compressed, false otherwise.
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
dP: CosDocThe Cos document to test.
true if the file contains the Adobe Extensions dictionary for the ISO 32000 standard, false otherwise.
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.
doc: CosDocThe document whose compression is checked.
true if the document is partially compressed, false otherwise.
ASBool CosDocObjIsWithinRange(CosObj obj, ASInt32 byteRanges[], ASInt32 numEntries)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.
true if the object begins within any of the given ranges and has not been modified, false otherwise.
ASBool CosDocObjIsWithinRange64(CosObj obj, ASFilePos64 byteRanges[], ASInt32 numEntries)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.
obj: CosObjThe Cos object (must be indirect).
byteRanges: ASFilePos64An array containing pairs of byte offsets within the document. Each pair is a start and end offset from the beginning of the document.
numEntries: ASInt32The number of byte offsets (not pairs) in the byteRanges array.
true if the object begins within any of the given ranges and has not been modified, false otherwise.
CosDoc CosDocOpenWithParams(CosDocOpenParams params)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 >>
params: CosDocOpenParamsSpecifies how to open the document.
A Cos document.
void CosDocSaveToFile(CosDoc cosDoc, ASFile asFile, CosDocSaveFlags saveFlags, CosDocSaveParams saveParams)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.
cosDoc: CosDocThe document to save.
asFile: ASFileThe file to which the document is written; it must be open in write mode. This file is not necessarily position-able.
saveFlags: CosDocSaveFlagsAn OR of the CosDocSaveFlags bit flag values specifying how to save the document.
saveParams: CosDocSaveParamsOptional parameters for use when saving a document, as described in CosDocSaveParams() .
voidSaves 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.void CosDocSaveWithParams(CosDoc cosDoc, ASFile asFile, CosDocSaveFlags saveFlags, CosDocSaveParams saveParams)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.
cosDoc: CosDocThe CosDoc for the document to save.
asFile: ASFileThe 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: CosDocSaveFlagsAn OR of the CosDocSaveFlags bit flag values specifying how to save the document.
saveParams: CosDocSaveParamsCosDocSaveParams parameters for use when saving the CosDoc document.
voidSaves a Cos document, optionally to a new file. It generates a cross-reference index (table or stream) by default.void CosDocSetAdobeExtensionLevel(CosDoc dP, CosObj baseVersion, ASUns32 extension)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
voidvoid CosDocSetDirty(CosDoc cosDoc, ASBool isDirty)Sets a Cos document's dirty flag to a given boolean value. If this flag is true when the document is closed, it indicates that the document must be saved to preserve changes.
voidvoid CosSetMaxDocStorage(ASInt32 maxMemory)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.
maxMemory: ASInt32The maximum amount of RAM (in bytes) that will be used to store fixed-size Cos objects.
voidtypedef ASBool(* CosDocEnumEOFsProc) (CosDoc cosDoc, ASFileOffset fileOffset, void *clientData))(CosDoc cosDoc, ASFileOffset fileOffset, void *clientData)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.
typedef ASBool(* CosDocEnumEOFsProc64) (CosDoc cosDoc, ASFileOffset64 fileOffset, void *clientData))(CosDoc cosDoc, ASFileOffset64 fileOffset, void *clientData)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.
0x10If 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.
0x04Do NOT use the newly saved file as new store, stay with the current one
4 items
char * CosCopyNameStringValue(CosObj obj, ASTCount *nBytes)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.
obj: CosObjIN 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.
char *A copy of the Cos object's name, as a NULL -terminated string.
ASAtom CosNameValue(CosObj obj)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.
obj: CosObjThe object of type CosName whose value is obtained.
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).
CosObj CosNewName(CosDoc dP, ASBool indirect, ASAtom name)Creates a new name object associated with the specified document and having the specified value.
dP: CosDocThe document in which the new name is used.
indirect: ASBoolIf 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: ASAtomThe 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() .
The newly created name Cos object.
CosObj CosNewNameFromString(CosDoc dP, ASBool indirect, const char *namestring)Creates a new name object associated with the specified document and having the specified value.
dP: CosDocThe document in which the new name is used.
indirect: ASBoolIf 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.)
The newly created name Cos object.
13 items
double CosDoubleValue(CosObj obj)Gets the value of obj as a double-precision floating-point real number.
An exception is raised if the given object has the wrong Cos type.
obj: CosObjdoubleThe numeric value of obj , represented as a floating-point number.
ASFixed CosFixedValue(CosObj obj)Gets the value of obj as a fixed-point real number.
obj: CosObjfloat CosFloatValue(CosObj obj)Gets the value of obj as a single-precision floating-point real number.
An exception is raised if the given object has the wrong Cos type.
obj: CosObjfloatThe numeric value of obj , represented as a floating-point number.
Gets the 64-bit integer value of a specified number object.
An exception is raised if the given object has the wrong Cos type.
obj: CosObjThe 64-bit integer value of obj .
ASInt32 CosIntegerValue(CosObj obj)Gets the 32-bit integer value of a specified number object. An exception is raised if the given object has the wrong Cos type.
obj: CosObjThe 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.
The 32-bit integer value of obj .
CosObj CosNewDouble(CosDoc dP, ASBool indirect, double value)Creates a new real-number object from a double-precision floating-point number associated with the specified document.
A Cos object of type CosReal ( CosFixed ).
CosObj CosNewDoubleEx(CosDoc dP, ASBool indirect, double value, ASUns8 numSigDigs)Creates a new real-number object from a double-precision floating-point number associated with the specified document.
A Cos object of type CosReal ( CosFixed ).
CosObj CosNewFixed(CosDoc dP, ASBool indirect, ASFixed value)Creates a new real-number object from a fixed-point number associated with the specified document.
A Cos object of type CosReal ( CosFixed ).
CosObj CosNewFloat(CosDoc dP, ASBool indirect, float value)Creates a new real-number object from a single-precision floating-point number associated with the specified document.
A Cos object of type CosReal ( CosFixed ).
CosObj CosNewInteger(CosDoc dP, ASBool indirect, ASInt32 value)Creates a new 32-bit integer object associated with the specified document and having the specified value.
An object of type CosInteger.
CosObj CosNewInteger64(CosDoc dP, ASBool indirect, ASInt64 value)Acrobat 7 additions Creates a new 64-bit integer object associated with the specified document and having the specified value.
dP: CosDocIN The document in which the integer is used.
indirect: ASBoolIN 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: ASInt64IN The value, represented as a 64-bit integer.
An object of type CosInteger.
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 ).
obj: CosObjA Cos integer or real number.
true if the value of the number is in the range of ASFixed , false otherwise.
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 ).
obj: CosObjA Cos integer or real number.
true if the value of the number is in the range of 32-bit integers, false otherwise.
27 items
CosObj CosNewNull(void)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);
: voidA NULL Cos object.
void CosObjAcquire(CosObj obj)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.
obj: CosObjA Cos object.
voidCompares 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 .
Returns zero if the two objects are equal, -1 if obj1 is less than obj2 , 1 if obj1 is greater than obj2 .
CosObj CosObjCopy(CosObj srcObj, CosDoc destDoc, ASBool copyIndirect)Copies a CosObj from one document to another (or the same document).
The CosObj which has been copied to the destination document.
void CosObjDestroy(CosObj obj)Destroys a Cos object. This method does nothing if obj is a direct scalar object, such as the NULL object. If a composite object (an array, dictionary or stream) is destroyed: All the direct objects in it are automatically destroyed. The indirect objects in it are not destroyed.
obj: CosObjThe object to destroy.
voidASBool CosObjEnum(CosObj obj, CosObjEnumProc proc, void *clientData)Enumerates the elements of a Cos object by calling a user-supplied procedure for each component of the object.
obj: CosObjproc: CosObjEnumProcA 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 true if every call to proc returned true . As soon as any call to proc returns false , the enumeration stops and CosObjEnum() returns false .
ASBool CosObjEqual(CosObj obj1, CosObj obj2)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 .
true if obj1 and obj2 are equal, false otherwise.
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() .
obj: CosObjThe object to test.
true if obj is compressible, false otherwise.
CosDoc CosObjGetDoc(CosObj obj)Gets the CosDoc containing the specified object. This is defined only for indirect or non-scalar objects.
obj: CosObjThe object whose CosDoc is obtained.
The object's CosDoc.
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).
obj: CosObjIN/OUT The indirect CosObj for which the generation number is obtained. A CosObj can be determined to be indirect using CosObjIsIndirect() .
The generation number of cosObj .
CosID CosObjGetID(CosObj obj)Gets the local master index for an indirect object. For indirect objects, the local master index is the same as the indirect object index that appears in the PDF file.
obj: CosObjIN/OUT The indirect CosObj for which the ID is obtained. A CosObj can be determined to be indirect using CosObjIsIndirect() .
The ID of obj .
obj: CosObjThe object whose type is obtained.
The object's type.
CosHashCode CosObjHash(CosObj obj)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.
obj: CosObjThe CosObj for which to obtain a hash code.
32-bit hash code for the given CosObj , or CosNewNull() if there is no object with this ID.
Tests whether an object is compressed (part of a CosObjCollection).
obj: CosObjThe object to test.
true if obj is compressed, false otherwise.
ASBool CosObjIsIndirect(CosObj obj)Tests whether an object is indirect.
obj: CosObjThe object to test.
true if obj is indirect, false if obj is direct.
void CosObjRefreshAfterLinearizedSave(CosObj *obj, CosDoc doc)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.
voidvoid CosObjRelease(CosObj obj)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.
obj: CosObjA Cos object.
voidvoid CosObjSetCompressibility(CosObj obj, ASBool compressible)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.
voidtrue if obj is marked as compressible, false otherwise.
Constants that specify a Cos object's type (string, number, dictionary, and so on).
typedef ASBool(* CosObjEnumProc) (CosObj obj, CosObj value, void *clientData))(CosObj obj, CosObj value, void *clientData)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.
typedef void(* CosObjOffsetProc) (CosObj obj, ASFilePos fileOffset, ASArraySize length, void *clientData))(CosObj obj, ASFilePos fileOffset, ASArraySize length, void *clientData)A callback for PDDocSaveParams() used by PDDocSaveWithParams(). Use this to get information about Cos objects of interest while a PDDoc is being saved.
typedef void(* CosObjOffsetProc64) (CosObj obj, ASFilePos64 fileOffset, ASUns64 length, void *clientData))(CosObj obj, ASFilePos64 fileOffset, ASUns64 length, void *clientData)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.
9 items
dP: CosDocThe newly created Cos object collection.
ASBool CosObjAddToCollection(CosObjCollection coll, CosObj item)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.
coll: CosObjCollectionThe Cos object collection.
item: CosObjThe object to add.
true if obj was successfully added to the collection, false otherwise.
ASBool CosObjCollectionEnum(CosObjCollection coll, CosObjEnumProc proc, void *clientData)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.
coll: CosObjCollectionThe object collection whose members are enumerated.
proc: CosObjEnumProcA 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 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 ).
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 ).
c1: CosObjCollectionAn object collection to compare.
c2: CosObjCollectionAn object collection to compare.
true if c1 and c2 are the same collection, false otherwise.
Tests whether an object collection is NULL . 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 .
coll: CosObjCollectionThe object collection to test.
true if coll is NULL , false otherwise.
Gets the number of objects in an object collection. The size of a NULL collection is zero.
coll: CosObjCollectionThe object collection whose size is obtained.
The number of objects in the collection.
Gets the CosObjCollection containing the specified object. If the object is not in a collection, the method raises an exception. An error is raised if obj is not in a collection.
obj: CosObjThe object whose CosObjCollection is obtained.
The CosObjCollection to which the object belongs.
void CosObjRemoveFromCollection(CosObj obj)Removes a Cos object from the CosObjCollection to which it belongs. An exception is raised if the object is not in the collection.
obj: CosObjThe object to remove.
void11 items
CosObj CosNewStream(CosDoc dP, ASBool indirect, ASStm stm, CosStreamStartAndCode sourceStart, ASBool encodeTheSourceData, CosObj attributesDict, CosObj encodeParms, CosByteMax sourceLength)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.
dP: CosDocThe Cos document in which the newly created stream will be used.
indirect: ASBoolMust 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: ASStmThe 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: CosStreamStartAndCodeThe 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: ASBoolDetermines 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: CosObjEither 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: CosObjThe 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: CosByteMaxThe 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.
The newly created stream Cos object.
CosObj CosNewStream64(CosDoc dP, ASBool indirect, ASStm stm, ASInt64 stmStartPos, ASBool stmDataIsDecoded, CosObj attributesDict, CosObj encodeParms, ASInt64 sourceLength, ASBool allowDelayedRead)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.
dP: CosDocThe Cos document in which the newly created stream will be used.
indirect: ASBoolMust always be true , specifying that the Cos stream is created as an indirect object.
stm: ASStmThe source stream containing the data to copy into the new stream.
stmStartPos: ASInt64Starting position for the stream. Its default is 0 .
stmDataIsDecoded: ASBoolA boolean value indicating whether the data in stm should be encoded using filters specified in attributesDict .
attributesDict: CosObjEither the NULL Cos object, or a direct Cos dictionary containing stream attributes.
encodeParms: CosObjThe parameters to be used by the filters if the source data is to be encoded.
sourceLength: ASInt64The amount of data to be read from the source.
allowDelayedRead: ASBoolIf 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.
The newly created stream Cos object.
CosObj CosStreamDict(CosObj stream)Gets a stream's attributes dictionary.
stream: CosObjIN/OUT The stream whose attributes dictionary is obtained.
The stream's attributes dictionary Cos object.
ASTArraySize CosStreamLength(CosObj stream)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.
stream: CosObjThe stream whose length is obtained.
The length of the stream.
ASInt64 CosStreamLength64(CosObj stream)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.
stream: CosObjThe stream whose length is obtained.
The length of the stream.
ASStm CosStreamOpenStm(CosObj stream, CosStreamOpenMode mode)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() .
stream: CosObjThe Cos stream object for which an ASStm is opened.
mode: CosStreamOpenModeThis must be one of the CosStreamOpenMode values.
The newly-opened ASStm .
ASTCount CosStreamPos(CosObj stream)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.
stream: CosObjASFilePos64 CosStreamPos64(CosObj stream)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.
stream: CosObjThe stream whose current position is obtained.
The byte offset of the start of the Cos stream's data in the PDF file.
typedef ASEnum8 CosStreamOpenModeConstants that specify whether filters and decryption should be applied to the stream's data.
6 items
char * CosCopyStringValue(CosObj obj, ASTCount *nBytes)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 aNULL-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.obj: CosObjnBytes: ASTCount *char *CosObj CosNewString(CosDoc dP, ASBool indirect, const char *str, ASTArraySize nBytes)Creates and returns a new Cos string object.
dP: CosDocindirect: ASBoolstr: const char *nBytes: ASTArraySizeASBool CosStringGetHexFlag(CosObj cosObj)Gets the hex flag of the CosString . The hex flag specifies whether the CosString should be written out as hex when writing the Cos Object to file.
cosObj: CosObjIN/OUT The CosString for which the hex flag is obtained.
The current value of the flag.
ASBool CosStringSetHexFlag(CosObj cosObj, ASBool setHex)Sets the hex flag of the CosString . The hex flag specifies whether the CosString should be written out as hex when writing the Cos Object to file.
The value of setHex .
char * CosStringValue(CosObj obj, ASTCount *nBytes)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.
obj: CosObjIN 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.
char *The value of obj .
char * CosStringValueSafe(CosObj obj, char *buffer, ASTArraySize bufferSize, ASTCount *nBytes)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.
obj: CosObjThe Cos object whose string value is copied.
buffer: char *The buffer into which the Cos string value is copied, or NULL .
bufferSize: ASTArraySizeThe 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.
char *A copy of the Cos string value or an exception. It will never return NULL .
1 items