Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created September 30, 2024 14:11
Show Gist options
  • Save bjoerntx/004bf565e5c7476090ff4a66b9c0cfc3 to your computer and use it in GitHub Desktop.
Save bjoerntx/004bf565e5c7476090ff4a66b9c0cfc3 to your computer and use it in GitHub Desktop.
using TXTextControl;
using (ServerTextControl tx = new ServerTextControl())
{
tx.Create();
tx.Tables.Add(5, 5, 10);
Table table = tx.Tables.GetItem(10);
// set and format the header row
table.Rows[1].IsHeader = true;
table.Rows[1].CellFormat = new TableCellFormat() {
BackColor = System.Drawing.Color.LightGray,
BottomBorderWidth = 10,
};
// set the cell text and format the cells
foreach (TableCell cell in table.Cells) {
if (table.Rows[cell.Row].IsHeader) { // header row
cell.Text = "Header Column " + cell.Column.ToString();
}
else { // data rows
cell.Text = "Row " + cell.Row.ToString() + ", Column " + cell.Column.ToString();
cell.CellFormat = new TableCellFormat()
{
BottomBorderWidth = 1,
TopBorderWidth = 1,
LeftBorderWidth = 1,
RightBorderWidth = 1
};
}
}
// save the document as PDF
tx.Save("results.pdf", StreamType.AdobePDF);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment