Create a signature field in PDF with multiple annotations

This is how this can be done with itext 4.1.6


PdfReader reader = new PdfReader(File.ReadAllBytes(@"...path to pdf..."));

MemoryStream outStream = new MemoryStream();

PdfStamper stamper = new PdfStamper(reader, outStream);            

PdfFormField field = PdfFormField.CreateSignature(stamper.Writer);
field.Page = 1;
field.FieldName = "test1";
field.SetPage();
field.SetWidget(new Rectangle(100, 100, 200, 200), PdfAnnotation.HIGHLIGHT_INVERT);

field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, 
      PdfTemplate.CreateTemplate(stamper.Writer, 0, 0));
field.Flags = PdfAnnotation.FLAGS_PRINT;
field.SetFieldFlags(PdfFormField.FF_REQUIRED);

field.Put(PdfName.DA, new PdfString("/Arial 0 Tf 0 g"));


stamper.AddAnnotation(field, 1);
stamper.AddAnnotation(field, 2);

stamper.Close();

Post a Comment

Previous Post Next Post