Dim caption As String = "Example: SetFormFieldValue"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
'Please use the PDF document created using the example from the AddFormFieldItem(Integer, String, String) method.
If gdpicturePDF.LoadFromFile("ListBox_ExportValue.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim message As String = "This document contains " + count.ToString() + " form fields." + vbCrLf
Dim formID As Integer = 0
Dim value As String = ""
Dim isMulti As Boolean = False
Dim type As PdfFormFieldType = PdfFormFieldType.PdfFormFieldTypeUnknown
For i As Integer = 0 To count - 1
formID = gdpicturePDF.GetFormFieldId(i)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
'Getting the form field's type.
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If type = PdfFormFieldType.PdfFormFieldTypeList Then
'Getting the form field's current value.
message = message + " current value: "
value = gdpicturePDF.GetFormFieldValue(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
'Setting the form field's new current value.
isMulti = gdpicturePDF.GetFormFieldMultiSelect(formID)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If isMulti Then
value = "German,French"
If gdpicturePDF.SetFormFieldValue(formID, value, ",") = GdPictureStatus.OK Then
value = gdpicturePDF.GetFormFieldValue(formID, ";")
message = message + " new value: "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + " setvalue: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
Else
value = "French"
If gdpicturePDF.SetFormFieldValue(formID, value) = GdPictureStatus.OK Then
value = gdpicturePDF.GetFormFieldValue(formID)
message = message + " new value: "
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
message = message + value
Else
message = message + gdpicturePDF.GetStat().ToString()
End If
message += vbCrLf
Else
message = message + " setvalue: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + " multiselection: " + gdpicturePDF.GetStat().ToString() + vbCrLf
End If
End If
Else
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Else
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString()
Exit For
End If
Next
If gdpicturePDF.SaveToFile("ListBox_NewValue.pdf") = GdPictureStatus.OK Then
message = message + vbCrLf + "The file has been saved successfully."
Else
message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetFormFieldValue";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Please use the PDF document created using the example from the AddFormFieldItem(Int, String, String) method.
if (gdpicturePDF.LoadFromFile("ListBox_ExportValue.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
string message = "This document contains " + count.ToString() + " form fields.\n";
int formID = 0;
string value = "";
bool isMulti = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
//Getting the form field's type.
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (type == PdfFormFieldType.PdfFormFieldTypeList)
{
//Getting the form field's current value.
message = message + " current value: ";
value = gdpicturePDF.GetFormFieldValue(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
//Setting the form field's new current value.
isMulti = gdpicturePDF.GetFormFieldMultiSelect(formID);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (isMulti)
{
value = "German,French";
if (gdpicturePDF.SetFormFieldValue(formID, value, ",") == GdPictureStatus.OK)
{
value = gdpicturePDF.GetFormFieldValue(formID, ";");
message = message + " new value: ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
message = message + " setvalue: " + gdpicturePDF.GetStat().ToString() + "\n";
}
else
{
value = "French";
if (gdpicturePDF.SetFormFieldValue(formID, value) == GdPictureStatus.OK)
{
value = gdpicturePDF.GetFormFieldValue(formID);
message = message + " new value: ";
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
message = message + value;
else
message = message + gdpicturePDF.GetStat().ToString();
message += "\n";
}
else
message = message + " setvalue: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
message = message + " multiselection: " + gdpicturePDF.GetStat().ToString() + "\n";
}
}
else
{
message = message + "The GetFormFieldType() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
else
{
message = message + "The GetFormFieldId() method has failed with the status: " + gdpicturePDF.GetStat().ToString();
break;
}
}
if (gdpicturePDF.SaveToFile("ListBox_NewValue.pdf") == GdPictureStatus.OK)
message = message + "\nThe file has been saved successfully.";
else
message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
MessageBox.Show(message, caption);
}
else
MessageBox.Show("The GetFormFieldsCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();