Scrittura dei valori dei campi di un form PDF

' Il seguente snippet può essere utilizzato come esempio per assegnare i valori ai campi testo e caselle contenuti in un form PDF
' Nell'esempio ai campi testo viene assegnato il nome, mentre le caselle vengono spuntate
' Per ulteriori info vedere qui: https://help.syncfusion.com/file-formats/pdf/working-with-forms

dim path as string=form.GetDocumentPath()

Dim loadedDocument As New Syncfusion.Pdf.Parsing.PdfLoadedDocument(path)

' Load the form from the loaded document
Dim frm As Syncfusion.Pdf.Parsing.PdfLoadedForm = loadedDocument.Form

' Load the form field collections from the form
Dim fieldCollection As Syncfusion.Pdf.Parsing.PdfLoadedFormFieldCollection = TryCast(frm.Fields, Syncfusion.Pdf.Parsing.PdfLoadedFormFieldCollection)

For i As Integer = 0 To fieldCollection.Count - 1

	If TypeOf fieldCollection(i) Is Syncfusion.Pdf.Parsing.PdfLoadedTextBoxField Then
	
		Dim loadedTextBoxField As Syncfusion.Pdf.Parsing.PdfLoadedTextBoxField = TryCast(fieldCollection(i), Syncfusion.Pdf.Parsing.PdfLoadedTextBoxField)
		
		loadedTextBoxField.Text=loadedTextBoxField.name
	Else
		if TypeOf fieldCollection(i) Is Syncfusion.Pdf.Parsing.PdfLoadedCheckBoxField
			Dim loadedCheckBoxField As Syncfusion.Pdf.Parsing.PdfLoadedCheckBoxField = TryCast(fieldCollection(i), Syncfusion.Pdf.Parsing.PdfLoadedCheckBoxField)
		
			loadedCheckBoxField.Checked=true
		Else
			if TypeOf fieldCollection(i) Is Syncfusion.Pdf.Parsing.PdfLoadedComboBoxField
				Dim loadedComboBoxField As Syncfusion.Pdf.Parsing.PdfLoadedComboBoxField = TryCast(fieldCollection(i), Syncfusion.Pdf.Parsing.PdfLoadedComboBoxField)
			
				loadedComboBoxField.SelectedValue=loadedComboBoxField.Name
			End If
		End If
	End If

Next i

loadedDocument.Save()
loadedDocument.Close(True)