ボタンオプション値の取得

既存のPDFファイルからボタンオプション値を取得する

ラジオボタンは、異なるオプションを表示する方法を提供します。Formクラスを使用すると、特定のラジオボタンのすべてのボタンオプション値を取得できます。これらの値は、GetButtonOptionValuesメソッドを使用して取得できます。このメソッドは、ラジオボタンの名前を入力パラメータとして要求し、Hashtableを返します。このHashtableを反復処理してオプション値を取得できます。以下のコードスニペットは、既存のPDFファイルからボタンオプション値を取得する方法を示しています。

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
private static void GetButtonOptions()
{    
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

    using (var pdfForm = new Aspose.Pdf.Facades.Form())
    {
        // Bind PDF document
        pdfForm.BindPdf(dataDir + "FormField.pdf");

        // Get button option values
        var optionValues = pdfForm.GetButtonOptionValues("Gender");

        IDictionaryEnumerator optionValueEnumerator = optionValues.GetEnumerator();

        while (optionValueEnumerator.MoveNext())
        {
            Console.WriteLine("Key : {0} , Value : {1} ", optionValueEnumerator.Key, optionValueEnumerator.Value);
        }
    }
}

既存のPDFファイルから現在のボタンオプション値を取得する

ラジオボタンはオプション値を設定する方法を提供しますが、一度に1つだけ選択できます。現在選択されているオプション値を取得したい場合は、GetButtonOptionCurrentValueメソッドを使用できます。Formクラスはこのメソッドを提供します。このメソッドは、ラジオボタンの名前を入力パラメータとして要求し、値を文字列として返します。以下のコードスニペットは、既存のPDFファイルから現在のボタンオプション値を取得する方法を示しています。

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.Pdf-for-.NET
private static void GetCurremtButtonOptionValue()
{    
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdfFacades_Forms();

    using (var pdfForm = new Aspose.Pdf.Facades.Form())
    {
        // Bind PDF document
        pdfForm.BindPdf(dataDir + "FormField.pdf");

        // Get button option values
        string optionValue = pdfForm.GetButtonOptionCurrentValue("Gender");

        Console.WriteLine("Current Value : {0} ", optionValue);
    }
}