flattenFields method

void flattenFields()

Flattens all form fields, merging their appearances into the page content.

Implementation

void flattenFields() {
  final fieldsList = fields.values.toList();
  for (final field in fieldsList) {
    _flattenField(field);
  }

  if (_fields.isEmpty) return;

  // Remove AcroForm from catalog
  document.catalog.params.values.remove(PdfNameTokens.acroForm);

  // Optionally remove the field objects from document.objects (complex as they are referenced elsewhere)
  // For now we just clear our internal map.
  _fields = {};
}