DL Logo

CosDoc Definitions

cosDocCreateInfoDict

Header: CosExpT.h:198

Syntax

#define cosDocCreateInfoDict 0x01

cosSaveBinaryOK

Header: CosExpT.h:208

Description

It is ok to store binary data in the file.

Syntax

#define cosSaveBinaryOK 0x08

cosSaveConcealObjStreams

Header: CosExpT.h:213

Description

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.

Syntax

#define cosSaveConcealObjStreams 0x10

cosSaveCopy

Header: CosExpT.h:206

Description

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

Syntax

#define cosSaveCopy 0x04

cosSaveFullSave

Header: CosExpT.h:204

Description

Write all objects, not just changes.

Syntax

#define cosSaveFullSave 0x02

cosSaveGarbageCollect

Header: CosExpT.h:202

Description

Delete unreferenced objects before save.

Syntax

#define cosSaveGarbageCollect 0x01

kCosDocOpenDoRepair

Header: CosExpT.h:173

Syntax

#define kCosDocOpenDoRepair 0x0001

CosDoc Typedefs

CosByte

Header: CosExpT.h:57

Description

Used for an array of bytes in CosDocGetID().

Syntax

typedef ASUns8 CosByte;

Used By

CosDoc

Header: CosExpT.h:94

Syntax

typedef struct _t_CosDoc *CosDoc;

Returned From

Used By

Used In

CosDocSaveFlags

Header: CosExpT.h:215

Syntax

typedef ASFlagBits CosDocSaveFlags;

Used By

CosDoc Callback Signatures

CosDocEnumEOFsProc

Header: CosExpT.h:273

Description

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.

Note: 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.

Related Methods

Syntax

ASBool CosDocEnumEOFsProc(CosDoc cosDoc, ASFileOffset fileOffset, void *clientData);

Parameters

cosDoc
The CosDoc in which the EOF is found.
fileOffset
The 31-bit offset into the file directly following the %%EOF keyword. If the procedure is called more than once, the file positions passed to it are in decreasing order (that is, the EOF positions are treated as rollback points).
clientData
User-supplied data that was passed in the call to CosDocEnumEOFs().

Returns

true to continue enumeration, false to halt the enumeration.

Used By

CosDocEnumEOFsProc64

Header: CosExpT.h:292

Description

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.

Related Methods

Syntax

ASBool CosDocEnumEOFsProc64(CosDoc cosDoc, ASFileOffset64 fileOffset, void *clientData);

Parameters

cosDoc
The CosDoc in which the EOF is found.
fileOffset
The 64-bit offset into the file directly following the %%EOF keyword.
clientData
User-supplied data that was passed in the call to CosDocEnumEOFs64().

Returns

true to continue enumeration, false to halt the enumeration.

Used By

CosDoc Structures

_t_CosDocOpenParams

Header: CosExpT.h:183

Description

Parameters used when saving a file using CosDocOpenWithParams().

Syntax

struct _t_CosDocOpenParams {
ASSize_t size;
The size of this struct.
ASFlagBits openFlags;
A bitfield of kCosDocOpen flags.
ASFileSys fileSys;
May be NULL if using the default file system.
ASPathName pathName;
Must be provided.
const char *headerString;
An expected header string (for example, "%ADF-"). If it is NULL, "%PDF-" is the assumed value.
} CosDocOpenParamsRec, *CosDocOpenParams;

Used By

_t_CosDocSaveParams

Header: CosExpT.h:225

Description

Parameters used when saving a file using CosDocSaveToFile() and CosDocSaveWithParams().

Syntax

struct _t_CosDocSaveParams {
ASSize_t size;
The size of this struct.
const char *header;
A complete header string, such as "%ADF-1.0".
char *cryptData;
The encryption key to pass into the PDCryptHandler if security has been set on the document.
ASTArraySize cryptDataLen;
The length of the encryption key in bytes. Cannot be greater than 5.
The progress monitor. Use AVAppGetDocProgressMonitor() to obtain the default progress monitor.
void *monClientData;
A pointer to user-supplied data to pass to mon each time it is called.
CosCryptVersion cryptVersion;
The Cos cryptographic version- the version of the algorithm that is used to encrypt and decrypt document data. cryptVersion equal to 0 is treated as cryptVersion equal to 1, to maintain backward compatibility.
} CosDocSaveParamsRec, *CosDocSaveParams;

Used By

CosDoc Functions

CosDocClose

Header: CosProcs.h:1075

Description

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

Related Methods

Syntax

void CosDocClose(CosDoc cosDoc);

Parameters

cosDoc
IN/OUT The document to close.

CosDocCreate

Header: CosProcs.h:1086

Description

Creates an empty Cos document.

Related Methods

Syntax

CosDoc CosDocCreate(ASFlagBits createFlags);

Parameters

createFlags
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

An empty Cos document.

CosDocEnumEOFs

Header: CosProcs.h:1276

Description

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.

Syntax

ASBool CosDocEnumEOFs(CosDoc cosDoc, CosDocEnumEOFsProc proc, void *clientData);

Parameters

cosDoc
The CosDoc in which the EOF's are enumerated.
proc
The CosDocEnumEOFsProc() to call for each EOF.
clientData
A pointer to user-supplied data to pass to proc each time it is called.

Returns

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

CosDocEnumEOFs64

Header: CosProcs.h:2213

Description

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.

Syntax

ASBool CosDocEnumEOFs64(CosDoc cosDoc, CosDocEnumEOFsProc64 proc, void *clientData);

Parameters

cosDoc
The CosDoc in which the EOF's are enumerated.
proc
The CosDocEnumEOFsProc64() to call for each EOF.
clientData
A pointer to user-supplied data to pass to proc each time it is called.

Returns

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

CosDocEnumIndirect

Header: CosProcs.h:1380

Description

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.

Related Methods

Syntax

ASBool CosDocEnumIndirect(CosDoc dP, CosObjEnumProc proc, void *clientData);

Parameters

dP
The CosDoc whose indirect objects are enumerated.
proc
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
A pointer to user-supplied data to pass to proc each time it is called.

Returns

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

CosDocGetAdobeExtensionLevel

Header: CosProcs.h:2446

Description

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

Syntax

ASBool CosDocGetAdobeExtensionLevel(CosDoc dP, CosObj *baseVersion, ASUns32 *extension);

Parameters

dP
IN The Cos document to test.
baseVersion
OUT The PDF version on which the extensions are based (will be of type CosName).
extension
OUT The level of the extension expressed as a monotonically increasing integer.

Returns

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

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

CosDocGetID

Header: CosProcs.h:1508

Description

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

Syntax

ASBool CosDocGetID(CosDoc dP, CosByte **pInstanceID, CosByte **pPermaID, ASTCount *instIDLength, ASTCount *permIDLength);

Parameters

dP
IN/OUT The CosDoc whose ID byte arrays are returned.
pInstanceID
IN/OUT (Filled by the method) The instance ID.
pPermaID
IN/OUT (Filled by the method) The permanent ID.
instIDLength
IN/OUT The length of pInstanceID in bytes.
permIDLength
IN/OUT The length of pPermaID in bytes.

Returns

true if the ID is returned, false otherwise.

CosDocGetInfoDict

Header: CosProcs.h:982

Description

Gets the specified document's Info dictionary. In general, access the document's Info dictionary using PDDocGetInfo() and PDDocSetInfo() wherever possible.

Syntax

CosObj CosDocGetInfoDict(CosDoc dP);

Parameters

dP
IN/OUT The document whose Info dictionary is obtained.

Returns

The document's Info dictionary Cos object.

CosDocGetObjByID

Header: CosProcs.h:1201

Description

Gets the indirect CosObj with the latest generation number.

Related Methods

Syntax

CosObj CosDocGetObjByID(CosDoc dP, CosID objNum);

Parameters

dP
The CosDoc to search for the matching Cos object.
objNum
The local master index for the indirect Cos object to return.

Returns

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.

CosDocGetRoot

Header: CosProcs.h:968

Description

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

Related Methods

Syntax

CosObj CosDocGetRoot(CosDoc dP);

Parameters

dP
IN/OUT The document whose Catalog is obtained.

Returns

The document's Catalog dictionary Cos object.

CosDocHasFullCompression

Header: CosProcs.h:1801

Description

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

Syntax

ASBool CosDocHasFullCompression(CosDoc doc);

Parameters

doc
The document whose compression is checked.

Returns

true if the document is fully compressed, false otherwise.

CosDocHasISOExtensions

Header: CosProcs.h:2424

Description

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

Syntax

ASBool CosDocHasISOExtensions(CosDoc dP);

Parameters

dP
The Cos document to test.

Returns

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

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

CosDocHasPartialCompression

Header: CosProcs.h:1831

Description

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.

Related Methods

Syntax

ASBool CosDocHasPartialCompression(CosDoc doc);

Parameters

doc
The document whose compression is checked.

Returns

true if the document is partially compressed, false otherwise.

CosDocObjIsWithinRange

Header: CosProcs.h:1580

Description

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.

Syntax

ASBool CosDocObjIsWithinRange(CosObj obj, ASInt32 byteRanges [], ASInt32 numEntries);

Parameters

obj
The Cos object (must be indirect).
byteRanges
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
The number of byte offsets (not pairs) in the byteRanges array.

Returns

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

CosDocObjIsWithinRange64

Header: CosProcs.h:2266

Description

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.

Syntax

ASBool CosDocObjIsWithinRange64(CosObj obj, ASFilePos64 byteRanges [], ASInt32 numEntries);

Parameters

obj
The Cos object (must be indirect).
byteRanges
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
The number of byte offsets (not pairs) in the byteRanges array.

Returns

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

CosDocOpenWithParams

Header: CosProcs.h:1065

Description

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

> >

Related Methods

Syntax

CosDoc CosDocOpenWithParams(CosDocOpenParams params);

Parameters

params
Specifies how to open the document.

Returns

A Cos document.

CosDocSaveToFile

Header: CosProcs.h:1132

Description

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.

Syntax

void CosDocSaveToFile(CosDoc cosDoc, ASFile asFile, CosDocSaveFlags saveFlags, CosDocSaveParams saveParams);

Parameters

cosDoc
The document to save.
asFile
The file to which the document is written; it must be open in write mode. This file is not necessarily position-able.
saveFlags
An OR of the CosDocSaveFlags bit flag values specifying how to save the document.
saveParams
Optional parameters for use when saving a document, as described in CosDocSaveParams().

Exceptions

CosDocSaveWithParams

Header: CosProcs.h:1246

Description

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

Syntax

void CosDocSaveWithParams(CosDoc cosDoc, ASFile asFile, CosDocSaveFlags saveFlags, CosDocSaveParams saveParams);

Parameters

cosDoc
The CosDoc for the document to save.
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
An OR of the CosDocSaveFlags bit flag values specifying how to save the document.
saveParams
CosDocSaveParams parameters for use when saving the CosDoc document.

Exceptions

CosDocSetAdobeExtensionLevel

Header: CosProcs.h:2464

Description

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

Syntax

void CosDocSetAdobeExtensionLevel(CosDoc dP, CosObj baseVersion, ASUns32 extension);

Parameters

dP
The Cos document to set.
baseVersion
The PDF version on which the extensions are based (will be of type CosName).
extension
The level of the extension expressed as a monotonically increasing integer.

CosDocSetDirty

Header: CosProcs.h:1147

Description

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.

Syntax

void CosDocSetDirty(CosDoc cosDoc, ASBool isDirty);

Parameters

cosDoc
The Cos document whose dirty flag is set.
isDirty
true if dirty, false otherwise.

CosSetMaxDocStorage

Header: CosProcs.h:1556

Description

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.

Syntax

void CosSetMaxDocStorage(ASInt32 maxMemory);

Parameters

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