PdfIndirectObjectCollection Class
The indirect objects of a document (ISO 32000-2, 7.3.10): the objects that references point to.
public sealed class PdfIndirectObjectCollectionRemarks
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
| Name | Description |
|---|---|
| Count | Gets the number of indirect objects, loaded or not. |
| MaxObjectNumber | Gets the highest object number in use. |
MaxObjectNumber
PdfIndirectObjectCollection.csMethods
| Name | Description |
|---|---|
| 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. |
Add(PdfObject)
PdfIndirectObjectCollection.csAdds an object as a new indirect object.
public PdfReference Add(PdfObject value)Parameters
valuePdfObject- 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.
GetReferences()
PdfIndirectObjectCollection.csGets the references to every indirect object, in the order of their numbers.
public IEnumerable<PdfReference> GetReferences()Returns
IEnumerable<PdfReference> The references.
Remove(PdfReference)
PdfIndirectObjectCollection.csRemoves an indirect object: the references to it then point to the null object (7.3.10).
public bool Remove(PdfReference reference)Parameters
referencePdfReference- 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.csGets the object a reference points to.
public PdfObject Resolve(PdfReference reference)Parameters
referencePdfReference- The reference.
Returns
PdfObject The object, or PdfNull.Instance when it does not exist or cannot be read.
Set(PdfReference, PdfObject)
PdfIndirectObjectCollection.csReplaces the value of an indirect object.
public void Set(PdfReference reference, PdfObject value)Parameters
referencePdfReference- The reference to the object.
valuePdfObject- The new value. It cannot be a reference.
TryGetReference(int, PdfReference?)
PdfIndirectObjectCollection.csGets the reference to an object by its number.
public bool TryGetReference(int objectNumber, out PdfReference? reference)Parameters
objectNumberint- The object number.
referencePdfReference?- The reference, with the generation of the object.
Returns
bool true when the object exists.