build method

  1. @override
void build(
  1. PdfPage page,
  2. PdfObject<PdfDataType> object,
  3. PdfDict<PdfDataType> params
)
override

Implementation

@override
void build(PdfPage page, PdfObject object, PdfDict params) {
  super.build(page, object, params);

  params['/FT'] = PdfName(fieldType);

  if (fieldName != null) {
    params['/T'] = PdfString.fromString(fieldName!);
  }

  final mk = PdfDict();
  if (color != null) {
    mk.values['/BC'] = PdfArray.fromColor(color!);
  }

  if (backgroundColor != null) {
    mk.values['/BG'] = PdfArray.fromColor(backgroundColor!);
  }

  if (mk.values.isNotEmpty) {
    params['/MK'] = mk;
  }

  if (highlighting != null) {
    switch (highlighting!) {
      case PdfAnnotHighlighting.none:
        params['/H'] = const PdfName('/N');
        break;
      case PdfAnnotHighlighting.invert:
        params['/H'] = const PdfName('/I');
        break;
      case PdfAnnotHighlighting.outline:
        params['/H'] = const PdfName('/O');
        break;
      case PdfAnnotHighlighting.push:
        params['/H'] = const PdfName('/P');
        break;
      case PdfAnnotHighlighting.toggle:
        params['/H'] = const PdfName('/T');
        break;
    }
  }
}