如何使用 iTextSharp 5.5.13 将签名字段添加到 pdf

How to add signature field to pdf using iTextSharp 5.5.13

我在 C# 中使用 iTextSharp 5.5.13 尝试了这段代码:

Document document = new Document();
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filename,FileMode.Create, FileAccess.Write));
document.Open();
document.Add(new Paragraph("Hello World!"));
PdfFormField field = PdfFormField.CreateSignature(writer);
field.setFieldName(SIGNAME);
field.SetPage();
field.SetWidget(new iTextSharp.text.Rectangle(72, 732, 144, 780), PdfAnnotation.HIGHLIGHT_INVERT);
field.SetFieldFlags(PdfAnnotation.FLAGS_PRINT);
writer.AddAnnotation(field);
PdfAppearance tp = PdfAppearance.CreateAppearance(writer, 72, 48);
tp.SetColorStroke(BaseColor.BLUE);
tp.SetColorFill(BaseColor.LIGHT_GRAY);
tp.Rectangle(0.5f, 0.5f, 71.5f, 47.5f);
tp.FillStroke();
tp.SetColorFill(BaseColor.BLUE);
ColumnText.ShowTextAligned(tp, Element.ALIGN_CENTER,
new Phrase("SIGN HERE"), 36, 24, 25);
field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
document.Close();

一切都很完美,除了 setFieldName

setFieldName 处显示错误:

Error CS1061 'PdfFormField' does not contain a definition for 'setFieldName' and no extension method 'setFieldName' accepting a first argument of type 'PdfFormField' could be found (are you missing a using directive or an assembly reference?)

以及如何设置

的字体大小
ColumnText.ShowTextAligned(tp, Element.ALIGN_CENTER, new Phrase("SIGN HERE"), 36, 24, 25);

尝试写而不是setFieldName:

field.FieldName = SIGNAME;