Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iTextSharp - How to add a PDFPRow to a PDFPTable?

Tags:

c#

itextsharp

I would like to add an array of PDFPCells to a PDFPRow, then add the PDFPRow to a PDFPTable, but I can't seem to find a method within PDFPTable for this.

There is however a PDFPTable.AddCell

Any ideas?

like image 296
Since_2008 Avatar asked Oct 28 '10 14:10

Since_2008


1 Answers

Check out the PdfPTable's Rows.Add() method which takes a PdfPRow, which you can construct using an array of PdfPCells.

Example:

// ...
PdfPTable table = new PdfPTable(5);
PdfPCell[] cells = new PdfPCell[] { new PdfPCell(GetCell("c1")),
                                    new PdfPCell(GetCell("c2")),
                                    new PdfPCell(GetCell("c3")),
                                    new PdfPCell(GetCell("c4")),
                                    new PdfPCell(GetCell("c5"))};
PdfPRow row = new PdfPRow(cells);
table.Rows.Add(row);
// ...

Where the method GetCell() returns a PdfPCell.

like image 134
Jay Riggs Avatar answered Oct 29 '22 11:10

Jay Riggs