Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created September 30, 2024 14:52
Show Gist options
  • Save bjoerntx/7c0f5d09532bf6c64eeca9ceb9ec364b to your computer and use it in GitHub Desktop.
Save bjoerntx/7c0f5d09532bf6c64eeca9ceb9ec364b to your computer and use it in GitHub Desktop.
using TXTextControl;
using (ServerTextControl tx = new ServerTextControl())
{
tx.Create();
// reusing the table cell format
TableCellFormat tableCellFormat = new TableCellFormat()
{
BottomBorderWidth = 1,
TopBorderWidth = 1,
LeftBorderWidth = 1,
RightBorderWidth = 1
};
// add a table
tx.Tables.Add(5, 5, 10);
Table table = tx.Tables.GetItem(10);
// select first cell
table.Cells[1, 1].Select();
tx.Selection.Length = 0;
// insert a nested table
tx.Tables.Add(2, 2);
// set text in nested table
foreach (TableCell cell in table.NestedTables[1].Cells)
{
cell.Text = "nested";
cell.CellFormat = tableCellFormat;
}
// set text and format in main table
foreach (TableCell cell in table.Cells)
{
if (cell.Text == "")
cell.Text = "main";
cell.CellFormat = tableCellFormat;
}
tx.Save("results.pdf", StreamType.AdobePDF);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment