예제 #1
0
        public void MakeSimpleTable()
        {
            PdfGeneratedDocument doc   = new PdfGeneratedDocument();
            PdfGeneratedPage     page  = doc.AddPage(PdfDefaultPages.Letter);
            PdfTable             table = new PdfTable(new PdfBounds(72, 300, 400, 400), "Arial", 12);

            table.HeaderFontName = "Arial Bold Italic";
            table.BorderStyle    = PdfTableBorderStyle.Grid;
            table.Columns.Add(new PdfTableColumn("Name", "Person", 120, PdfTextAlignment.Center,
                                                 8, 8));
            table.Columns.Add(new PdfTableColumn("Age", "Age", 60, PdfTextAlignment.Center, 8,
                                                 8));
            table.Columns.Add(new PdfTableColumn("Color", "Favorite Color", 0,
                                                 PdfTextAlignment.Center, 8, 8));
            List <Person> people = new List <Person>()
            {
                new Person()
                {
                    Name = "John", Age = 15, Color = "Orange"
                },
                new Person()
                {
                    Name = "Emily", Age = 37, Color = "Blue"
                },
                new Person()
                {
                    Name = "Philippe", Age = 19, Color = "Green"
                },
                new Person()
                {
                    Name = "Jill", Age = 23, Color = "Ochre"
                }
            };

            table.AddRows(people.GetEnumerator());
            table.Fill(doc.Resources.Fonts);
            page.DrawingList.Add(table);
            doc.Save("basictable.pdf");
        }