I want to retrieve the values of filled form fields on this PDF. This is my code:
public virtual void ManipulatePdf(String src, String dest) {
PdfDocument pdf = new PdfDocument(new PdfReader(src), new PdfWriter(dest));
List<PdfAnnotation> annotArray = new List<PdfAnnotation>(pdf.GetFirstPage().GetAnnotations());
Console.WriteLine(annotArray.Count);
for (int i = 0; i < annotArray.Count; i++)
{
Console.Write(annotArray[i]);
Console.Write(", ");
Console.Write(annotArray[i].GetTitle());
Console.Write(", ");
if (annotArray[i].GetContents() is null){Console.Write("null");}
else {Console.Write(annotArray[i].GetContents());}
Console.WriteLine("");
}
pdf.Close();
}
The code prints out 145 widget annotations like so: iText.Kernel.Pdf.Annot.PdfWidgetAnnotation, CharacterName, null
All the annotations have their correct name, but no content, all null. How do I get the strings and check values contained within?