Posted by a ceTe Software moderator
Hello Bernhard,
You can set the required width and height for the TextArea, this will add the text which will fit in specified dimension. Below is the code sample.
Document document = new Document();
Table2 tableObj = new Table2(0, 0, 404, 100);
Column2 col1 = tableObj.Columns.Add(200);
Column2 col2 = tableObj.Columns.Add(200);
string text = "This some test text::";
for (int i = 0; i < 7; i++)
{
text = text + text;
}
Row2 row1 = tableObj.Rows.Add();
Cell2 R1C1 = row1.Cells.Add(text);
R1C1.Splittable = true;
Cell2 R1C2 = row1.Cells.Add("some text");
R1C2.Splittable = true;
//Set the required width and height for the TextArea to clip the contents.
TextArea area = new TextArea(text, 0, 0, 200, 20);
Row2 row2 = tableObj.Rows.Add(20);
Cell2 R2C1 = row2.Cells.Add(area);
Cell2 R2C2 = row2.Cells.Add("some text");
//Adding table to page.
do
{
Page page=new Page();
tableObj.Height = tableObj.GetRequiredHeight();
if (tableObj.Height > page.Dimensions.Body.Height)
{
tableObj.Height = page.Dimensions.Body.Height;
}
else
{
tableObj.Height = tableObj.Height;
}
page.Elements.Add(tableObj);
document.Pages.Add(page);
tableObj = tableObj.GetOverflowRows();
}
while (tableObj != null);
document.Draw(@"C:\Temp\Mydocument.pdf");
Thanks,
ceTe Software Support Team.