使用Itextsharp在PDF中创建单选按钮

时间:2015-09-02 10:29:30

标签: pdf radio-button itextsharp

我正在使用以下代码创建PDF格式的单选按钮:

RadioCheckField checkBox = new RadioCheckField(PDFStamper.Writer, FieldBound, item.Name, item.Value == null ? "On" : item.Value);
PdfFormField field = checkBox.CheckField;
PdfFormField radiogroup = PdfFormField.CreateRadioButton(PDFStamper.Writer, true);
radiogroup.FieldName = (string.IsNullOrEmpty(item.GroupName) ? item.Name : item.GroupName);

checkBox.Alignment = Element.ALIGN_CENTER;
checkBox.BackgroundColor = new iTextSharp.text.Color(System.Drawing.Color.White);
checkBox.Checked = (item.Value.ToLower() == "true" ? true : false);
//checkBox.FieldName = (string.IsNullOrEmpty(item.GroupName) ? item.Name : item.GroupName);
checkBox.UserName = item.ToolTip;
checkBox.CheckType = RadioCheckField.TYPE_CIRCLE;
// checkBox.ByDefaultCheck = true;

field = checkBox.RadioField;
radiogroup.AddKid(field);

if (item.ReadOnly)
    checkBox.Options = checkBox.Options | BaseField.READ_ONLY;

if (item.Required)
    checkBox.Options = checkBox.Options | BaseField.REQUIRED;

PDFStamper.AddAnnotation(radiogroup, item.PageNumber);

使用相同的组名创建了两个单选按钮,但是当我以PDF格式打开文件时,只显示一个单选按钮。我错过了什么?

0 个答案:

没有答案