dictFor method

PdfDict<PdfDataType>? dictFor(
  1. PdfIndirect reference
)

The dictionary of reference, ready to take changes.

Returns null when the reference does not resolve to a dictionary.

Implementation

PdfDict<PdfDataType>? dictFor(PdfIndirect reference) {
  final existing = _materialized(reference);
  if (existing is PdfDict<PdfDataType>) return existing;

  final source = store.resolveDict(reference);
  if (source == null) return null;

  // Shallow copy: the values keep pointing to the same objects, which stay
  // in the original file.
  final copy =
      PdfDict<PdfDataType>.values(Map<String, PdfDataType>.of(source.values));
  _replace(reference, copy);
  return copy;
}