iTextSharp - 如何将PDFPRow添加到PDFPTable?

问题描述:

我想将一个PDFPCell数组添加到PDFPRow中,然后将PDFPRow添加到PDFPTable中,但我似乎无法在PDFPTable中找到一个方法。

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.

然而有一个PDFPTable.AddCell

There is however a PDFPTable.AddCell

任何想法?

查看 PdfPTable Rows.Add()方法,该方法采用PdfPRow,你可以使用 PdfPCells 数组构造。

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

示例:

// ...
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);
// ...

方法 GetCell() 返回 PdfPCell