iTextSharp - How to add a PDFPRow to a PDFPTable?

折月煮酒 提交于 2019-12-21 10:32:33

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/4043848/itextsharp-how-to-add-a-pdfprow-to-a-pdfptable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!