الحصول على قيمة خيار الزر

الحصول على قيم خيارات الزر من ملف 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 موجود

توفر أزرار الاختيار وسيلة لتعيين قيم الخيارات، ومع ذلك يمكن اختيار واحد منها فقط في كل مرة. إذا كنت ترغب في الحصول على قيمة الخيار المحدد حاليًا، يمكنك استخدام [GetButtonOptionCurrentValue** method. توفر فئة Form هذه الطريقة. تتطلب طريقة GetButtonOptionCurrentValue اسم زر الاختيار كمعامل إدخال وتعيد القيمة كسلسلة. يوضح لك مقتطف الشيفرة التالي كيفية الحصول على قيمة خيار الزر الحالي من ملف 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);
    }
}