Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
单选按钮提供了一种显示不同选项的方法。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);
}
}
}
单选按钮提供了一种设置选项值的方法,但一次只能选择其中一个。如果您想获取当前选定的选项值,则可以使用 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);
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.