PdfPTable table = new PdfPTable(3); // 3 columns table.HorizontalAlignment = Element.ALIGN_LEFT; table.WidthPercentage = 100; table.AddCell("Column 1"); table.AddCell("Column 2"); table.AddCell("Column 3"); table.CompleteRow(); // add a new row with all cells filled
PdfPTable table = new PdfPTable(4); // 4 columns table.HorizontalAlignment = Element.ALIGN_LEFT; table.WidthPercentage = 100; table.AddCell("Name"); table.AddCell("Address"); table.AddCell("Phone"); table.AddCell("Email"); table.CompleteRow(); // add a new row with all cells filled table.AddCell("John Smith"); table.AddCell("123 Main St."); table.AddCell("555-1234"); table.AddCell("[email protected]"); table.CompleteRow(); // add a new row with all cells filledThis example creates a table with 4 columns and fills the first row with column headers. The CompleteRow() method is used to add a new row to the table with all the cells filled. Then, data is added to the table by filling in the cells of the second row and calling CompleteRow() again to add a new row to the table. In conclusion, the iTextSharp.text.pdf package library in C# provides the PdfPTable class with CompleteRow() method to create and fill tables in PDF documents.