I am trying to fill the fields of pdf form and have the following code:
string filePath = @"c:\test.pdf";
string newPath = @"E\Result";
if(File.Exists(filePath))
{
PdfDocument document = PdfReader.Open(filePath, PdfDocumentOpenMode.Modify);
// Get the root object of all interactive form fields
PdfAcroForm form = document.AcroForm;
// Get all form fields of the whole document
PdfAcroField.PdfAcroFieldCollection fields = document.AcroForm.Fields; //"/Fields"
string[] names = fields.Names;
names = fields.DescendantNames;
}
The problem is that it give error "A PDF name must start with a slash (/)
".
I discovered that document.AcroForm
has 4 pairs, one of them has key "/Fields". How do I reach it?