addSignatureField method

PdfDocument addSignatureField({
  1. required int pageNumber,
  2. required PdfRect bounds,
  3. required String fieldName,
  4. void drawAppearance(
    1. PdfGraphics graphics,
    2. PdfRect bounds
    )?,
})

Adds a signature field at the given bounds.

Implementation

PdfDocument addSignatureField({
  required int pageNumber,
  required PdfRect bounds,
  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 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;
}