PdfWriter writer = findWriter();
if (writer == null) {
throw new RuntimeException("Cannot find PdfWriter - the document may not exist or may not be a pdf type");
}
PdfAcroForm form = writer.getAcroForm();
field = (String) valueBinding(context, "field", field);
if (field == null) {
throw new RuntimeException("signature field named is required");
}
size = (String) valueBinding(context, "size", size);
if (size == null) {
throw new RuntimeException("signature size is required");
}
float[] rect = ITextUtils.stringToFloatArray(size);
if (rect.length != 4) {
throw new RuntimeException("size must contain four numbers");
}
form.addSignature(field, rect[0], rect[1], rect[2], rect[3]);
UIDocument doc = (UIDocument) findITextParent(this, UIDocument.class);
doc.addSignature(this);
super.encodeEnd(context);