Пример #1
0
            public override void Draw(DrawContext context)
            {
                int          pageNumber = GetOccupiedArea().GetPageNumber();
                Rectangle    bbox       = GetInnerAreaBBox();
                PdfDocument  pdf        = context.GetDocument();
                PdfAcroForm  form       = PdfAcroForm.GetAcroForm(pdf, true);
                PdfFormField chk        = PdfFormField.CreateRadioButton(pdf, bbox, _group, _value, PdfAConformanceLevel.PDF_A_1B
                                                                         );

                chk.SetPage(pageNumber);
                chk.SetValue("Off");
                chk.RegenerateField();
                chk.SetVisibility(PdfFormField.VISIBLE);
                chk.SetBorderColor(ColorConstants.BLACK);
                chk.SetBackgroundColor(ColorConstants.WHITE);
                chk.SetReadOnly(true);
                PdfFormXObject appearance = new PdfFormXObject(bbox);
                PdfCanvas      canvas     = new PdfCanvas(appearance, pdf);

                canvas.SaveState().MoveTo(bbox.GetLeft(), bbox.GetBottom()).LineTo(bbox.GetRight(), bbox.GetBottom()).LineTo
                    (bbox.GetRight(), bbox.GetTop()).LineTo(bbox.GetLeft(), bbox.GetTop()).LineTo(bbox.GetLeft(), bbox.GetBottom
                                                                                                      ()).SetLineWidth(1f).Stroke().RestoreState();
                form.AddFieldAppearanceToPage(chk, pdf.GetPage(pageNumber));
                chk.SetAppearance(PdfName.N, "v1".Equals(_value) ? _value : "Off", appearance.GetPdfObject());
            }