DL Logo

CosObj Typedefs

CosGeneration

Header: CosExpT.h:44

Syntax

typedef ASUns16 CosGeneration;

Returned From

CosHashCode

Header: CosExpT.h:48

Description

0 is not valid.

Syntax

typedef ASUns32 CosHashCode;

Returned From

CosID

Header: CosExpT.h:46

Syntax

typedef ASUns32 CosID;

Returned From

Used By

CosObj

Header: CosExpT.h:96

Syntax

typedef OPAQUE_64_BITS CosObj;

Returned From

Used By

Used In

CosType

Header: CosExpT.h:90

Description

Constants that specify a Cos object's type (string, number, dictionary, and so on).

Syntax

typedef ASInt32 CosType;

Returned From

Used In

CosObj Callback Signatures

CosObjEnumProc

Header: CosExpT.h:132

Description

A callback for CosObjEnum(), CosDocEnumIndirect(), and PDDocEnumOCGs(). It is called once for each component of a composite Cos object (dictionary, array, and stream).

Related Methods

Syntax

ASBool CosObjEnumProc(CosObj obj, CosObj value, void *clientData);

Parameters

obj
Possible values:
Value
Description
Dictionary
A key.
Array
An array element.
Stream
The stream's dictionary (the whole thing, not one key at a time).
value
Possible values:
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.

clientData
User-supplied data that was passed in the call to CosObjEnum(), CosDocEnumIndirect(), or PDDocEnumOCGs().

Returns

true to continue enumeration, false to halt enumeration.

Used By

CosObjOffsetProc

Header: CosExpT.h:308

Description

A callback for PDDocSaveParams() used by PDDocSaveWithParams(). Use this to get information about Cos objects of interest while a PDDoc is being saved.

Related Methods

Syntax

void CosObjOffsetProc(CosObj obj, ASFilePos fileOffset, ASArraySize length, void *clientData);

Parameters

obj
IN/OUT The CosObj found.
fileOffset
IN/OUT The offset of obj into the PDF file.
length
IN/OUT The length of obj.
clientData
IN/OUT A pointer to user-supplied data passed in the offsetProcClientData parameter of the PDDocSaveParams structure.

Used In

CosObjOffsetProc64

Header: CosExpT.h:311

Syntax

void CosObjOffsetProc64(CosObj obj, ASFilePos64 fileOffset, ASUns64 length, void *clientData);

Used In

CosObjSetCallbackFlagProc

Header: CosExpT.h:326

Description

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.

Related Methods

Syntax

ASBool CosObjSetCallbackFlagProc(CosObj obj, ASBool set);

Parameters

obj
IN/OUT The CosObj marked.
set
IN/OUT true to set the flag to be called back during the save, false otherwise.

Used In

CosObj Functions

CosNewNull

Header: CosProcs.h:141

Description

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);

Related Methods

Syntax

CosObj CosNewNull(void);

Returns

A NULL Cos object.

CosObjAcquire

Header: CosProcs.h:2127

Description

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.

Syntax

void CosObjAcquire(CosObj obj);

Parameters

obj
A Cos object.

CosObjCmp

Header: CosProcs.h:1544

Description

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:

Related Methods

Syntax

ASInt32 CosObjCmp(CosObj obj1, CosObj obj2);

Parameters

obj1
The first CosObj to compare.
obj2
The second CosObj to compare.

Returns

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

CosObjCopy

Header: CosProcs.h:1332

Description

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

Related Methods

Syntax

CosObj CosObjCopy(CosObj srcObj, CosDoc destDoc, ASBool copyIndirect);

Parameters

srcObj
The CosObj to copy.
destDoc
The CosDoc for the document into which the CosObj is copied.
copyIndirect
true if all indirectly referenced objects from srcObj are copied to destDoc, false otherwise.

Returns

The CosObj which has been copied to the destination document.

CosObjDestroy

Header: CosProcs.h:489

Description

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.

Syntax

void CosObjDestroy(CosObj obj);

Parameters

obj
The object to destroy.

CosObjEnum

Header: CosProcs.h:106

Description

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

Syntax

ASBool CosObjEnum(CosObj obj, CosObjEnumProc proc, void *clientData);

Parameters

obj
    The object whose elements are enumerated.
  • For scalars or strings, the proc is not called, and CosObjEnum() returns true.
  • For dictionaries, proc is called for each key-value pair. The order in which the key-value pairs are enumerated is undefined.
  • For arrays, proc is called with each element as the first paramater to proc, and the NULL object as the second parameter. Array elements are enumerated in ascending order of index.
  • For streams, proc is called once, with the stream's dictionary as the first parameter to the proc and the NULL object as the second parameter.
proc
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
A pointer to user-supplied data to pass to proc each time it is called.

Returns

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

Header: CosProcs.h:55

Description

    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.

Related Methods

Syntax

ASBool CosObjEqual(CosObj obj1, CosObj obj2);

Parameters

obj1
An object to compare with obj2.
obj2
An object to compare with obj1.

Returns

true if obj1 and obj2 are equal, false otherwise.

CosObjGetCompressibility

Header: CosProcs.h:1709

Description

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().

Syntax

ASBool CosObjGetCompressibility(CosObj obj);

Parameters

obj
The object to test.

Returns

true if obj is compressible, false otherwise.

CosObjGetDoc

Header: CosProcs.h:118

Description

Gets the CosDoc containing the specified object. This is defined only for indirect or non-scalar objects.

Related Methods

Syntax

CosDoc CosObjGetDoc(CosObj obj);

Parameters

obj
The object whose CosDoc is obtained.

Returns

The object's CosDoc.

Exceptions

is raised if the object is a direct scalar object.

CosObjGetGeneration

Header: CosProcs.h:1186

Description

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).

Syntax

CosGeneration CosObjGetGeneration(CosObj obj);

Parameters

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

Returns

The generation number of cosObj.

Exceptions

is raised if the object is not valid or is not indirect.

CosObjGetID

Header: CosProcs.h:1167

Description

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.

Syntax

CosID CosObjGetID(CosObj obj);

Parameters

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

Returns

The ID of obj.

Exceptions

is raised if the object is not valid or is not indirect.

CosObjGetType

Header: CosProcs.h:63

Description

Gets an object's type.

Syntax

CosType CosObjGetType(CosObj obj);

Parameters

obj
The object whose type is obtained.

Returns

The object's type.

CosObjHash

Header: CosProcs.h:1317

Description

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.

Related Methods

Syntax

CosHashCode CosObjHash(CosObj obj);

Parameters

obj
The CosObj for which to obtain a hash code.

Returns

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

CosObjIsCompressed

Header: CosProcs.h:1588

Description

Tests whether an object is compressed (part of a CosObjCollection).

Syntax

ASBool CosObjIsCompressed(CosObj obj);

Parameters

obj
The object to test.

Returns

true if obj is compressed, false otherwise.

CosObjIsIndirect

Header: CosProcs.h:71

Description

Tests whether an object is indirect.

Syntax

ASBool CosObjIsIndirect(CosObj obj);

Parameters

obj
The object to test.

Returns

true if obj is indirect, false if obj is direct.

CosObjRefreshAfterLinearizedSave

Header: CosProcs.h:1779

Description

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.

Syntax

void CosObjRefreshAfterLinearizedSave(CosObj *obj, CosDoc doc);

Parameters

obj
A pointer to the object to refresh. The object is updated by the method.
doc
The document that was saved.

CosObjRelease

Header: CosProcs.h:2141

Description

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.

Syntax

void CosObjRelease(CosObj obj);

Parameters

obj
A Cos object.

CosObjSetCompressibility

Header: CosProcs.h:1689

Description

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.

Syntax

void CosObjSetCompressibility(CosObj obj, ASBool compressible);

Parameters

obj
The object whose compressibility is set.
compressible
true if the object can be made part of a CosObjCollection, false otherwise.

Returns

true if obj is marked as compressible, false otherwise.