Geeks With Blogs
Deeksha Sharma
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTextSharp;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.IO;

namespace PDFFormGenerator
{
    class Program
    {
        public static String[] LANGUAGES_gc = { "English", "German", "Spanish" };

        static void Main(string[] args)
        {
            Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
            PdfWriter wri = PdfWriter.GetInstance(doc, new FileStream(@"E:\test.pdf", FileMode.Create));
            doc.Open();
            doc.AddAuthor("Test author");
            doc.AddCreationDate();
            PdfContentByte cb = wri.DirectContent;
            Font _bf = new Font(Font.FontFamily.HELVETICA, 6);
            PdfFormField _radioGroup = PdfFormField.CreateRadioButton(wri, true);
            _radioGroup.FieldName = "language_gc";
            Rectangle _rect;
            RadioCheckField _radioG;
            PdfFormField _radioField1;
            for (int i = 0; i < LANGUAGES_gc.Length; i++)
            {
                _rect = new Rectangle(46, 806 - i * 40, 60, 788 - i * 40);
                _radioG = new RadioCheckField(wri, _rect, null, LANGUAGES_gc[i]);
                _radioG.BackgroundColor = new GrayColor(0.8f);
                _radioG.BorderColor = GrayColor.BLACK;
                _radioG.CheckType = RadioCheckField.TYPE_CIRCLE;
                _radioField1 = _radioG.RadioField;
                _radioGroup.AddKid(_radioField1);
                ColumnText.ShowTextAligned(cb, Element.ALIGN_LEFT, new Phrase(LANGUAGES_gc[i], new Font(Font.FontFamily.HELVETICA, 18)), 70, 790 - i * 40, 0);
            }
            wri.AddAnnotation(_radioGroup);
            cb = wri.DirectContent;
            doc.Close();          
        }
    }
}

Posted on Thursday, July 17, 2014 5:36 AM | Back to top


Comments on this post: Radio button in Pdf using itextsharp

# re: Radio button in Pdf using itextsharp
Requesting Gravatar...
How to set radio button in Editable PDF
Left by set radio button in Editable PDF on Jul 19, 2017 6:15 AM

Your comment:
 (will show your gravatar)


Copyright © Deeksha Sharma | Powered by: GeeksWithBlogs.net