I test some layout with tables
If the text is to long for the width of a Cell: then the cell is expanded in height?
Is it possible to set the cell-property, so the overflowing text is clipped?
-bernhard
Cell2 to small for text
Re: Cell2 to small for text
Support · Feb 26, 2019Hi Bernard,
Not directly. However, you could place a TextArea in the cell to get this result. Here is a topic on placing a page element in a cell:
Adding Page Elements to Cells
Thanks,
ceTe Software Support Team
Re: Cell2 to small for text
Forum member · Feb 27, 2019Thanks.
Now I looked at the documentation about FormattedTextArea.
But maybe I'm a little tired and blind, but I coludn't get it, how to clip text.
Maybe you can get me one more hint (or two ;-)
-bernhard
Re: Cell2 to small for text
Support · Feb 27, 2019Hello 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.