Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created September 30, 2024 15:08
Show Gist options
  • Save bjoerntx/be6d174c9202b5269bdd92866b0154e7 to your computer and use it in GitHub Desktop.
Save bjoerntx/be6d174c9202b5269bdd92866b0154e7 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 the cell text and format the cells
foreach (TableCell cell in table.Cells)
{
cell.Text = "Row " + cell.Row.ToString() + ", Column " + cell.Column.ToString();
cell.CellFormat = new TableCellFormat()
{
BottomBorderWidth = 1,
TopBorderWidth = 1,
LeftBorderWidth = 1,
RightBorderWidth = 1
};
}
table.Rows[5].AllowPageBreak = false;
string randomLongText = "This is a very long text that should be wrapped to the next line.";
// create a loop that repeats this text
for (int i = 0; i < 4; i++)
{
randomLongText += " " + randomLongText;
}
// add long content to first cell of the last row
table.Cells[5,1].Text = randomLongText;
// 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