在新页面上呈现每个PdfPCell

时间:2014-02-04 12:20:26

标签: itextsharp

我需要在新页面中渲染每个单元格值。

我使用以下代码:

List<string> values = getValues(); // getValues() method returns a list of strings
Document doc = new Document();
....
PdfPTable table = new PdfPTable(1);
foreach(var s in values)
{
    table.AddCell(s);
    doc.NewPage();
}
...

但我在单页中获得输出。

1 个答案:

答案 0 :(得分:4)

在每个页面上添加一个单元格表格:

List<string> values = getValues(); // getValues() method returns a list of strings
Document doc = new Document();
....
foreach(var s in values)
{
    PdfPTable table = new PdfPTable(1);
    table.AddCell(s);
    doc.add(table);
    doc.NewPage();
}
...