Cell2 to small for text

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v9)  /  Cell2 to small for text

DynamicPDF CoreSuite for .NET (v9) Forum

 Feb 26 2019 3:52 PM
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
 Feb 26 2019 4:29 PM
Posted by a ceTe Software moderator
Hi 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
 Feb 27 2019 2:05 AM
Thanks.

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
 Feb 27 2019 12:00 PM
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.

All times are US Eastern Standard time. The time now is 11:45 AM.