Skip to content

Commit 2e5eb46

Browse files
pavel-alayiText-CI
authored andcommitted
Fix radio group processing in RadioRenderer
DEVSIX-2408 Autoported commit. Original commit hash: [0069d19a]
1 parent d77f583 commit 2e5eb46

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

itext/itext.html2pdf/itext/html2pdf/attach/impl/layout/form/renderer/RadioRenderer.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,26 @@ public virtual bool IsBoxChecked() {
125125
*/
126126
protected internal override void ApplyAcroField(DrawContext drawContext) {
127127
PdfDocument doc = drawContext.GetDocument();
128+
PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, true);
128129
Rectangle area = flatRenderer.GetOccupiedArea().GetBBox().Clone();
129130
PdfPage page = doc.GetPage(occupiedArea.GetPageNumber());
130131
String groupName = this.GetProperty<String>(Html2PdfProperty.FORM_FIELD_VALUE);
131-
PdfButtonFormField radioGroup = (PdfButtonFormField)PdfAcroForm.GetAcroForm(doc, true).GetField(groupName);
132+
PdfButtonFormField radioGroup = (PdfButtonFormField)form.GetField(groupName);
133+
bool addNew = false;
132134
if (null == radioGroup) {
133135
radioGroup = PdfFormField.CreateRadioGroup(doc, groupName, "on");
136+
addNew = true;
134137
}
135138
if (IsBoxChecked()) {
136139
radioGroup.SetValue(GetModelId());
137140
}
138-
PdfButtonFormField field = (PdfButtonFormField)PdfFormField.CreateRadioButton(doc, area, radioGroup, GetModelId
139-
());
140-
field.SetCheckType(PdfFormField.TYPE_CIRCLE);
141-
PdfAcroForm.GetAcroForm(doc, true).AddField(radioGroup, page);
141+
PdfFormField.CreateRadioButton(doc, area, radioGroup, GetModelId()).SetCheckType(PdfFormField.TYPE_CIRCLE);
142+
if (addNew) {
143+
form.AddField(radioGroup, page);
144+
}
145+
else {
146+
form.ReplaceField(GetModelId(), radioGroup);
147+
}
142148
}
143149

144150
protected internal override bool IsLayoutBasedOnFlatRenderer() {

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b918991643cd64873966ecff706735218ac94491
1+
0069d19adc644a97d7d04ae8630a851e36ed2199

0 commit comments

Comments
 (0)