build method

  1. @override
PdfAnnot build(
  1. Context context,
  2. PdfRect? box
)
override

Implementation

@override
PdfAnnot build(Context context, PdfRect? box) {
  final globalPoints = points
      .map((pList) => pList
          .map((e) => context.localToGlobalPoint(e))
          .toList(growable: false))
      .toList(growable: false);

  final allPoints =
      points.expand((pointList) => pointList).toList(growable: false);

  final minX = allPoints.map((point) => point.x).reduce(min);
  final minY = allPoints.map((point) => point.y).reduce(min);
  final maxX = allPoints.map((point) => point.x).reduce(max);
  final maxY = allPoints.map((point) => point.y).reduce(max);
  final rect =
      context.localToGlobal(PdfRect(minX, minY, maxX - minX, maxY - minY));

  final pdfAnnotInk = PdfAnnotInk(
    context.document,
    globalPoints,
    rect: rect,
    border: border,
    color: color,
    date: date,
    author: author,
    subject: subject,
    content: content,
  );

  return PdfAnnot(
    context.page,
    pdfAnnotInk,
    objser: replaces?.ser,
    objgen: replaces?.gen ?? 0,
  );
}