addSignatureFieldTopLeft method

PdfDocument addSignatureFieldTopLeft({
  1. required int pageNumber,
  2. required double left,
  3. required double top,
  4. required double width,
  5. required double height,
  6. required String fieldName,
  7. void drawAppearance(
    1. PdfGraphics graphics,
    2. PdfRect bounds
    )?,
})

Adds a signature field using top-left coordinates.

Implementation

PdfDocument addSignatureFieldTopLeft({
  required int pageNumber,
  required double left,
  required double top,
  required double width,
  required double height,
  required String fieldName,
  void Function(PdfGraphics graphics, PdfRect bounds)? drawAppearance,
}) {
  final pageIndex = pageNumber - 1;
  if (pageIndex < 0 || pageIndex >= pdfPageList.pages.length) {
    throw RangeError.index(pageIndex, pdfPageList.pages, 'pageNumber');
  }

  final page = pdfPageList.pages[pageIndex];
  final bounds = _rectFromTopLeft(
    page,
    left: left,
    top: top,
    width: width,
    height: height,
  );
  final widget = PdfAnnotSign(rect: bounds, fieldName: fieldName);
  if (drawAppearance != null) {
    final g = widget.appearance(this, PdfAnnotAppearance.normal);
    drawAppearance(g, PdfRect(0, 0, bounds.width, bounds.height));
  }
  PdfAnnot(page, widget);
  return this;
}