measure method

  1. @override
PdfPoint measure(
  1. PdfDocument document
)
override

Size of the stamp, in display points.

Implementation

@override
PdfPoint measure(PdfDocument document) {
  final naturalWidth = image.width.toDouble();
  final naturalHeight = image.height.toDouble();
  final w = width;
  final h = height;
  if (w != null && h != null) return PdfPoint(w, h);
  if (w != null) {
    return PdfPoint(w, naturalWidth == 0 ? 0 : naturalHeight * w / naturalWidth);
  }
  if (h != null) {
    return PdfPoint(
        naturalHeight == 0 ? 0 : naturalWidth * h / naturalHeight, h);
  }
  return PdfPoint(naturalWidth, naturalHeight);
}