Fügen Sie eine checkbox mit iTextSharp

Ich versuche, fügen Sie einfach eine checkbox mit der iTextSharp-Bibliothek für C#. Ich habe folgte einige Beispiele und versucht, Sie zu ändern, weil Sie zeigen, wie Sie erstellen eine Gruppe von Kontrollkästchen. Wie erstelle ich einen?!

private static void WriteFooter(Document doc, int page, int maxPages, bool lastPage, PdfWriter writer, PdfAppearance[] checkBoxAppearance)
    {
        if(!lastPage)
        {
            doc.Add(new Paragraph("\nMA-2028.1-F2(Portrait) Page " + page + " of " + maxPages, Fonts.ExtraSmall));
            doc.NewPage();
        } else
        {
            PdfContentByte cb = writer.DirectContent;
            PdfFormField _checkGroup = PdfFormField.CreateRadioButton(writer, true);
            RadioCheckField _radioG;
            PdfFormField _radioField1;
            _radioG = new RadioCheckField(writer, new Rectangle(20, 20), null, "Yes");
            _radioG.CheckType = RadioCheckField.TYPE_CHECK;
            _radioField1 = _radioG.RadioField;
            _checkGroup.AddKid(_radioField1);
            ColumnText.ShowTextAligned(cb, Element.ALIGN_RIGHT, new Phrase("No Users Require Deletion"), 20, 20, 0);
            writer.AddAnnotation(_checkGroup);
            cb = writer.DirectContent;
            doc.Add(
                new Paragraph(
                    "Operations Management:\n\n", Fonts.Small) { Alignment = Element.ALIGN_CENTER });
            doc.Add(
                new Paragraph(
                    "Automation Manager or Designee: \n\n", Fonts.Small) { Alignment = Element.ALIGN_CENTER });
        }
    }

Schriftsteller, und checkBoxAppearance übergeben werden aus einer anderen Funktion. Zuvor in meinem code, erstelle ich eine Tabelle mit Checkboxen, aber ich muss hinzufügen, eine außerhalb dieser Tabelle. Ich folgte den code aus http://simpledotnetsolutions.wordpress.com/2012/11/01/itextsharp-creating-form-fields/

checkBoxAppearance ist ein array definiert das Verhalten der checkbox.

Und versucht es zu ändern, habe einfach eine checkbox. Ich bin auch versucht, um text zu zeigen, bis neben.

BEARBEITEN:
Ich bin auch versuchen, diese:

private static void WriteFooter(Document doc, int page, int maxPages, bool lastPage, PdfWriter writer, PdfFormField checkboxField, PdfAppearance[] checkbox, PdfContentByte cb)
    {
        if(!lastPage)
        {
            doc.Add(new Paragraph("\nMA-2028.1-F2(Portrait) Page " + page + " of " + maxPages, Fonts.ExtraSmall));
            doc.NewPage();
        } else
        {
            PdfFormField field;
            RadioCheckField checkBox;

            for (int i = 0; i < 1; i++ )
            {
                checkBox = new RadioCheckField(writer, new Rectangle(20, 20), "noDelete", "Yes");
                field = checkBox.CheckField;
                field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", checkbox[0]);
                field.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Yes", checkbox[1]);
                writer.AddAnnotation(field);
                //ColumnText.ShowTextAligned(cb, Element.ALIGN_RIGHT, new Phrase("No Users Need Deletion"), 210, 790, 0);
            }
            doc.Add(
                new Paragraph(
                    "Operations Management:\n\n", Fonts.Small) { Alignment = Element.ALIGN_CENTER });
            doc.Add(
                new Paragraph(
                    "Automation Manager or Designee:\n\n", Fonts.Small) { Alignment = Element.ALIGN_CENTER });
        }
    }

InformationsquelleAutor user | 2014-03-05

Schreibe einen Kommentar