Tables: The Workhorse Element
Harry
· 24 Sep 2026
· 1 views
Log in to track your progress and mark lessons complete.
Basic Table
import com.itextpdf.layout.element.*;
Table table = new Table(3); // 3 columns
table.addCell("Name");
table.addCell("Dept");
table.addCell("Salary");
table.addCell("Nisha");
table.addCell("IT");
table.addCell("75000");
document.add(table);Header Rows and Column Widths
Table t = new Table(new float[]{3, 2, 2}); // relative widths
t.addHeaderCell("Name");
t.addHeaderCell("Dept");
t.addHeaderCell("Salary");
// ... data cells ...Header cells repeat automatically on every page the table spans. Style headers with a background: cell.setBackgroundColor(new DeviceRgb(15, 118, 110)).