버튼 옵션 값 가져오기

기존 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 메서드를 사용할 수 있습니다. 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);
    }
}