flatten method

bool flatten(
  1. PdfAnnotationView view
)

Flattens view: draws its normal appearance on the page and removes it.

Refuses and records a warning when the annotation has no usable /AP /N or has no /Rect: claiming it was flattened without drawing anything would lose the content silently. Returns true when the annotation was drawn and removed.

Implementation

bool flatten(PdfAnnotationView view) {
  final rect = view.rect;
  if (rect == null || rect.isEmpty) {
    _warnings.add('Anotação ${view.reference ?? 'direta'} sem /Rect '
        'utilizável: não foi achatada.');
    return false;
  }

  final appearance = view.normalAppearance;
  if (appearance == null) {
    _warnings.add('Anotação ${view.reference ?? 'direta'} '
        '${view.missingAppearanceReason ?? 'sem /AP /N utilizável'}: '
        'não foi achatada.');
    return false;
  }

  painter.paint(appearance, rect);
  return remove(view);
}