How to add rows and pages in the PDF


I see in Aspose.Pdf docs, is there some code that allows rows and pages to be created from a loop? I see that the all examples are hardcoded.

Hi Junmil,

Thanks for contacting support.

Aspose.Pdf offers the features to create dynamic PDF files and you can add rows, pages and other PDF objects at run time. You can also bind a datasource and generate PDF files based on contents being retrieved from database.


the Document object by calling its empty constructor<o:p></o:p>

Document doc = new Document();

Page page = doc.Pages.Add();

//Instantiate a table object

Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();

//Add the table in paragraphs collection of the desired section


//Set with column widths of the table

tab1.ColumnWidths = "50 50 50";

//Set default cell border using BorderInfo object

tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);

//Set table border using another customized BorderInfo object

tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F);

//Create MarginInfo object and set its left, bottom, right and top margins

Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo();

margin.Top = 5f;

margin.Left = 5f;

margin.Right = 5f;

margin.Bottom = 5f;

//Set the default cell padding to the MarginInfo object

tab1.DefaultCellPadding = margin;

//Create rows in the table and then cells in the rows

Aspose.Pdf.Row row1 = tab1.Rows.Add();




TextFragment mytext = new TextFragment("col3 with large text string");

//row1.Cells.Add("col3 with large text string to be placed inside cell");


row1.Cells[2].IsWordWrapped = false;

//row1.Cells[2].Paragraphs[0].FixedWidth= 80;

for (int counter = 0; counter <= 100; counter++)


Aspose.Pdf.Row row2 = tab1.Rows.Add();





//Save the Pdf


Hi Junmil,

Thanks for your inquriy. Please check following documentation link to create table rows/cells in a loop. You can create pages and table/rows/cells in loop using Aspose.Pdf. In case you find any issue then please share the details so we will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,