PdfIndirectObjectCollection Class

The indirect objects of a document (ISO 32000-2, 7.3.10): the objects that references point to.

public sealed class PdfIndirectObjectCollection

Remarks

The objects of a file are loaded when a reference is first resolved. The collection is not thread-safe: a document supports one operation at a time.

Properties

NameDescription
CountGets the number of indirect objects, loaded or not.
MaxObjectNumberGets the highest object number in use.

Gets the number of indirect objects, loaded or not.

public int Count { get; }

Property value

int

Gets the highest object number in use.

public int MaxObjectNumber { get; }

Property value

int

Methods

NameDescription
Add(PdfObject)Adds an object as a new indirect object.
GetReferences()Gets the references to every indirect object, in the order of their numbers.
Remove(PdfReference)Removes an indirect object: the references to it then point to the null object (7.3.10).
Resolve(PdfReference)Gets the object a reference points to.
Set(PdfReference, PdfObject)Replaces the value of an indirect object.
TryGetReference(int, PdfReference?)Gets the reference to an object by its number.

Adds an object as a new indirect object.

public PdfReference Add(PdfObject value)

Parameters

value PdfObject
The object. It cannot be a reference.

Returns

PdfReference The reference to the new object.

Exceptions

InvalidOperationException
No object number is left: the file uses the highest numbers.

Gets the references to every indirect object, in the order of their numbers.

public IEnumerable<PdfReference> GetReferences()

Returns

IEnumerable<PdfReference> The references.

Remove(PdfReference)

PdfIndirectObjectCollection.cs

Removes an indirect object: the references to it then point to the null object (7.3.10).

public bool Remove(PdfReference reference)

Parameters

reference PdfReference
The reference to the object.

Returns

bool true when the object was removed; false when it does not exist.

Remarks

A full save does not write the object, and writes the references to it as null. An incremental save writes a free entry for its number, with the next generation (ISO 32000-2, 7.5.4): the object no longer exists in the new revision, and the earlier revisions keep it. The number is not given to a new object.

Resolve(PdfReference)

PdfIndirectObjectCollection.cs

Gets the object a reference points to.

public PdfObject Resolve(PdfReference reference)

Parameters

reference PdfReference
The reference.

Returns

PdfObject The object, or PdfNull.Instance when it does not exist or cannot be read.

Set(PdfReference, PdfObject)

PdfIndirectObjectCollection.cs

Replaces the value of an indirect object.

public void Set(PdfReference reference, PdfObject value)

Parameters

reference PdfReference
The reference to the object.
value PdfObject
The new value. It cannot be a reference.

TryGetReference(int, PdfReference?)

PdfIndirectObjectCollection.cs

Gets the reference to an object by its number.

public bool TryGetReference(int objectNumber, out PdfReference? reference)

Parameters

objectNumber int
The object number.
reference PdfReference?
The reference, with the generation of the object.

Returns

bool true when the object exists.