Form Field Name Discovery

I have received a 30 page pdf from a client with hundreds of form fields. I need to build a web UI and populate the pdf from based on their input. The problem I am having is linking the web UI input fields to the pdf form fields. Here's an examle to clarify:

Web UI PDF

txtName txtString3 (Located somewhere on page 5 of pdf)

Normally I would open Adobe LiveCycle to figure out the form field names but the pdf is secured and the client is not willing to provide us with the password so we can view the pdf in edit mode. I have exported the form fields to XML but I have no idea where a given form field is located on the PDF and they don't appear to be in order in the XML.

As a workaround I was hoping to print out the form field name next to the pdf field. Is there a way to do this? For TextBox fields I can easily set their value equal to the form field name, but how do I handle radio buttons and checkboxes? I am relatively new with Aspose and am looking for some direction.

I resolved this issue. I discovered the PdfFileSecurity class which allowed me to change the password of the document. I can now view the pdf in edit mode.

Hi,

As you have mentioned in your previous post, you are not aware of the owner password and the client is not sharing it. I am not sure how did you managed to change the password over Pdf file, because the PdfFileSecurity.ChangePassword() method requires, old owner password.

Dear Mr. Brandt,

Thanks for considering Aspose.Pdf.Kit.

We totally understood your requirement. You want to obtain the exact fieldname of each field in a huge document with so many fields. The solution depends on the type of the doc, if it is AcroForm PDF, the following code will be fine:

//get all field names
Form form = new Form (path + "Fields.pdf");
String[] allfields = form.FieldsNames;
System.Drawing.Rectangle[] box = new System.Drawing.Rectangle[allfields.Length];
for (int i = 0; i < allfields.Length; i++)
{
FormFieldFacade facade = form.GetFieldFacade(allfields[i]);
box[i] = facade.Box;
}
form.Save();
//add a textfield just upon the original one
FormEditor editor = new FormEditor(path + "Fields.pdf", path + "Fields.out.pdf");
for (int i = 0; i < allfields.Length; i++)
{
editor.AddField(FieldType.Text, "TextField" + i, allfields[i], 1, box[i].Left, box[i].Top, box[i].Left + 50, box[i].Top + 10);
}
editor.Save();

However, if it is a XfaForm PDF, since AddField() is invalid in such environment, you need another workaround. If you are not sure, please attach your file, thanks.

Best regards.