/* (non-Javadoc) * @see com.itextpdf.html2pdf.attach.impl.layout.form.renderer.AbstractFormFieldRenderer#applyAcroField(com.itextpdf.layout.renderer.DrawContext) */ protected internal override void ApplyAcroField(DrawContext drawContext) { PdfDocument doc = drawContext.GetDocument(); PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, true); Rectangle area = flatRenderer.GetOccupiedArea().GetBBox().Clone(); PdfPage page = doc.GetPage(occupiedArea.GetPageNumber()); String groupName = this.GetProperty <String>(Html2PdfProperty.FORM_FIELD_VALUE); PdfButtonFormField radioGroup = (PdfButtonFormField)form.GetField(groupName); bool addNew = false; if (null == radioGroup) { radioGroup = PdfFormField.CreateRadioGroup(doc, groupName, "on"); addNew = true; } if (IsBoxChecked()) { radioGroup.SetValue(GetModelId()); } PdfFormField radio = PdfFormField.CreateRadioButton(doc, area, radioGroup, GetModelId()); radio.SetCheckType(PdfFormField.TYPE_CIRCLE); if (addNew) { form.AddField(radioGroup, page); } else { form.ReplaceField(GetModelId(), radioGroup); } WriteAcroFormFieldLangAttribute(doc); }
protected void ManipulatePdf(String dest) { PdfDocument pdfDoc = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest)); PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, true); PdfFormField button = form.CopyField("Test"); PdfArray rect = button.GetWidgets()[0].GetRectangle(); // Increase value of the right coordinate (index 2 corresponds with right coordinate) rect.Set(2, new PdfNumber(rect.GetAsNumber(2).FloatValue() + 172)); button.SetValue("Print Amended"); form.ReplaceField("Test", button); pdfDoc.Close(); }