PdfObjectStore class

Single resolution point for the indirect objects of a PdfDocument.

Replaces the linear scans each subsystem used to run over document.objects: the store indexes the objects by PdfObjectId and resolves in O(1).

Index invalidation

PdfDocument.objects is a public, mutable Set — any code can add or remove objects without telling anyone. The index is built on demand and rebuilt whenever the size of the set changes. A swap that keeps the size (removing one object and adding another between two lookups) is not detectable by size; call invalidate in that case.

Document loaded from a file

When the document comes from a file (document.prev != null), most of the graph stays in the original bytes: only the catalog, the page tree and what was changed exist as PdfObject. By passing the source PdfDocumentParser to the constructor, the store starts falling back to the parser when the object is not materialized, converting the value read with the PdfObjectConverter and the PdfReferencePolicy.preserve policy: in a loaded document the object numbers from the file still hold, so there is no remapping.

These objects coming from the parser are only a read view:

  • they live in a cache owned by the store and do not enter document.objects, because rewriting them in the incremental update would duplicate the object definition needlessly;
  • from an object with a stream only the dictionary comes; the body stays reachable through the parser (readStreamData).

Turning that view into a recorded mutation is the job of the editing session (F2), not of the store.

Without a parser, the store sees only what is already materialized — that is how the current callers use it, to preserve the behavior they had with the manual scan.

Constructors

PdfObjectStore(PdfDocument document, {PdfDocumentParser? parser, PdfObjectConverter converter = PdfObjectConverter.preserving})
Creates a store over document.
PdfObjectStore.forDocument(PdfDocument document, {PdfObjectConverter converter = PdfObjectConverter.preserving})
Creates a store already bound to the source parser of document, if any.
factory

Properties

document → PdfDocument
The indexed document.
final
hashCode → int
The hash code for this object.
no setterinherited
hasSourceParser → bool
Whether the store can fall back to the source parser.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

containsId(PdfObjectId id) → bool
Whether id already exists as a materialized object of the document.
invalidate() → void
Discards the index; the next lookup rebuilds it.
lookup(PdfIndirect ref) → PdfObject<PdfDataType>?
Object pointed to by ref, or null if there is none.
lookupId(PdfObjectId id) → PdfObject<PdfDataType>?
Object with identity id, or null if there is none.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve(PdfDataType? value, {int maxDepth = 32}) → PdfDataType?
Follows the indirect references of value down to a direct value.
resolveArray(PdfDataType? value, {int maxDepth = 32}) → PdfArray<PdfDataType>?
Resolves value and returns the array, or null if it is not one.
resolveDict(PdfDataType? value, {int maxDepth = 32}) → PdfDict<PdfDataType>?
Resolves value and returns the dictionary, or null if it is not one.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

of(PdfDocument document) → PdfObjectStore
Shared store of document, without a source parser.