normalAppearance property

PdfAppearanceStream? get normalAppearance

The normal appearance of this annotation, or null when there is no usable one.

When /AP /N is a dictionary of states, the state is chosen by /AS; if there is a single state and no /AS, that one is used. A dictionary of several states without /AS is ambiguous and returns null — making the state up would mean deciding for the document.

Implementation

PdfAppearanceStream? get normalAppearance {
  final appearances = _store.resolveDict(dictionary[PdfNameTokens.ap]);
  if (appearances == null) return null;

  final normal = appearances[PdfNameTokens.n];
  final direct = _formStream(normal, null);
  if (direct != null) return direct;

  final states = _store.resolveDict(normal);
  if (states == null) return null;

  final selected = dictionary[PdfNameTokens.as];
  var state = selected is PdfName ? selected.value : null;
  if (state == null && states.values.length == 1) {
    state = states.values.keys.first;
  }
  if (state == null) return null;

  return _formStream(states[state], state);
}