Trying to clone the Signature of a SignatureField leads to InvalidOperationException as the FieldName of the cloned signature is already set.
Workaround: Remove the signatures before the merging of the document:
private static void RemoveSignatures(RadFixedDocument document)
{
List<FormField> signatures = document.AcroForm.FormFields.Where(ff => ff.FieldType == FormFieldType.Signature).ToList();
if (signatures.Count > 0)
{
foreach (FormField signature in signatures)
{
document.AcroForm.FormFields.Remove(signature);
}
}
List<SignatureWidget> signatureWidgets = document.Annotations.Where(a => a.Type == AnnotationType.Widget && a.GetType() == typeof(SignatureWidget)).Cast<SignatureWidget>().ToList();
if (signatureWidgets.Count > 0)
{
foreach (var signatureWidget in signatureWidgets)
{
foreach (RadFixedPage page in document.Pages)
{
if (page.Annotations.Contains(signatureWidget))
{
page.Annotations.Remove(signatureWidget);
}
}
}
}
}