officefileapi-devexpress-dot-pdf-dot-pdfdocumentprocessor-62756794.md
Returns an object containing values of interactive form data fields.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Docs.v25.2.dll
NuGet Package : DevExpress.Document.Processor
public PdfFormData GetFormData()
Public Function GetFormData As PdfFormData
| Type | Description |
|---|---|
| PdfFormData |
A PdfFormData object.
|
After the interactive form is changed, previously obtained interactive form data becomes invalid. The following operations change the interactive form:
Call the GetFormData method again to get valid interactive form data.
The code sample below uses PdfFormData to set form field values:
// Load a document with an interactive form.
using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor()) {
documentProcessor.LoadDocument(filePath + fileName + ".pdf");
// Obtain interactive form data from a document.
PdfFormData formData = documentProcessor.GetFormData();
// Specify the value for FirstName and LastName text boxes.
formData["FirstName"].Value = "Janet";
formData["LastName"].Value = "Leverling";
// Specify the value for the Gender radio group.
formData["Gender"].Value = "Female";
// Specify the check box checked appearance name.
formData["Check"].Value = "Yes";
// Specify values for the Category list box.
formData["Category"].Value = new string[] { "Entertainment", "Meals", "Morale" };
// Obtain data from the Address form field and specify values for Address child form fields.
PdfFormData address = formData["Address"];
// Specify the value for the Country combo box.
address["Country"].Value = "United States";
// Specify the value for City and Address text boxes.
address["City"].Value = "California";
address["Address"].Value = "20 Maple Avenue";
// Apply data to the interactive form.
documentProcessor.ApplyFormData(formData);
// Save the modified document.
documentProcessor.SaveDocument(filePath + fileName + "_new.pdf");
}
' Load a document with an interactive form.
Using documentProcessor As New PdfDocumentProcessor()
documentProcessor.LoadDocument(filePath & fileName & ".pdf")
' Obtain interactive form data from a document.
Dim formData As PdfFormData = documentProcessor.GetFormData()
' Specify the value for FirstName and LastName text boxes.
formData("FirstName").Value = "Janet"
formData("LastName").Value = "Leverling"
' Specify the value for the Gender radio group.
formData("Gender").Value = "Female"
' Specify the check box checked appearance name.
formData("Check").Value = "Yes"
' Specify values for the Category list box.
formData("Category").Value = New String() { "Entertainment", "Meals", "Morale" }
' Obtain data from the Address form field and specify values for Address child form fields.
Dim address As PdfFormData = formData("Address")
' Specify the value for the Country combo box.
address("Country").Value = "United States"
' Specify the value for City and Address text boxes.
address("City").Value = "California"
address("Address").Value = "20 Maple Avenue"
' Apply data to the interactive form.
documentProcessor.ApplyFormData(formData)
' Save the modified document.
documentProcessor.SaveDocument(filePath & fileName & "_new.pdf")
End Using
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetFormData() method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
pdf-document-api-fill-interactive-form-fields/CS/PdfFormFilling/PdfFormFilling.cs#L26
// Get names of interactive form fields.
PdfFormData formData = documentProcessor.GetFormData();
IList<string> names = formData.GetFieldNames();
pdf-document-api-fill-interactive-form-fields/VB/PdfFormFilling/PdfFormFilling.vb#L26
' Get names of interactive form fields.
Dim formData As PdfFormData = documentProcessor.GetFormData()
Dim names As IList(Of String) = formData.GetFieldNames()
See Also