Dim caption As String = "Example: GetFormFieldRadioInUnison"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("forms.pdf", False) = GdPictureStatus.OK Then
Dim count As Integer = gdpicturePDF.GetFormFieldsCount()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If count = 0 Then
MessageBox.Show("This document does not contain any forms.", caption)
Else
Dim title As String = ""
Dim formID As Integer = 0
Dim isUnison As Boolean = False, save 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 Exit For
type = gdpicturePDF.GetFormFieldType(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If type = PdfFormFieldType.PdfFormFieldTypeRadioButton Then
title = gdpicturePDF.GetFormFieldTitle(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
isUnison = gdpicturePDF.GetFormFieldRadioInUnison(formID)
If gdpicturePDF.GetStat() <> GdPictureStatus.OK Then Exit For
If isUnison Then
If gdpicturePDF.SetFormFieldRadioInUnison(formID, False) <> GdPictureStatus.OK Then Exit For
save = True
End If
End If
Next
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If save Then
If gdpicturePDF.SaveToFile("forms_updated.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
Else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("This document does not contain any radio buttons.", caption)
End If
Else
MessageBox.Show("Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End If
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: GetFormFieldRadioInUnison";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("forms.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetFormFieldsCount();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (count == 0)
MessageBox.Show("This document does not contain any forms.", caption);
else
{
string title = "";
int formID = 0;
bool isUnison = false, save = false;
PdfFormFieldType type = PdfFormFieldType.PdfFormFieldTypeUnknown;
for (int i = 0; i < count; i++)
{
formID = gdpicturePDF.GetFormFieldId(i);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
type = gdpicturePDF.GetFormFieldType(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (type == PdfFormFieldType.PdfFormFieldTypeRadioButton)
{
title = gdpicturePDF.GetFormFieldTitle(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
isUnison = gdpicturePDF.GetFormFieldRadioInUnison(formID);
if (gdpicturePDF.GetStat() != GdPictureStatus.OK) break;
if (isUnison)
{
if (gdpicturePDF.SetFormFieldRadioInUnison(formID, false) != GdPictureStatus.OK) break;
save = true;
}
}
}
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if (save)
{
if (gdpicturePDF.SaveToFile("forms_updated.pdf") == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
else
MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("This document does not contain any radio buttons.", caption);
}
else
MessageBox.Show("Something goes wrong. Status: " + gdpicturePDF.GetStat().ToString(), 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();