• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support

Create Table

Creates and renders a table on a PDF page.

Code

using DRIT.Pdf;

using var doc = new PdfDocument();
var page = doc.Pages.Add(PdfPageSize.A4);
var content = page.Content;

// Create a table
var table = new PdfTable(3, 4); // 3 columns, 4 rows

// Set column widths
table.Columns[0].Width = 100;
table.Columns[1].Width = 200;
table.Columns[2].Width = 200;

// Add header row
table.Rows[0].Cells[0].Text = "Column 1";
table.Rows[0].Cells[1].Text = "Column 2";
table.Rows[0].Cells[2].Text = "Column 3";

// Add data rows
table.Rows[1].Cells[0].Text = "Cell 1,1";
table.Rows[1].Cells[1].Text = "Cell 1,2";
table.Rows[1].Cells[2].Text = "Cell 1,3";

// Render the table
content.DrawTable(table, new PdfPoint(100, 600));

doc.Save("table.pdf");

Output

table.pdf

  • Improve this Doc
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX