Question

I need to render each cell values in a new page.

I am using the following code :

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();
}
...

But I am getting the output in a single page.

Was it helpful?

Solution

Add a one-cell table on each page:

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();
}
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top