No Wrap Equivalent?

5 posts, 0 answers
  1. Dan
    Dan avatar
    124 posts
    Member since:
    Feb 2011

    Posted 08 Jul 2015 Link to this post

    I do not know what the data going into the PDF will look like - and would like to be able to set Number and Date cells/columns to not wrap by default.  Is this possible?  
  2. Nikolay Demirev
    Admin
    Nikolay Demirev avatar
    103 posts

    Posted 09 Jul 2015 Link to this post

    Hello Dan,

    Try using the following code:
    table.LayoutType = TableLayoutType.AutoFit;

    I hope this helps.

    Regards,
    Nikolay Demirev
    Telerik
  3. Dan
    Dan avatar
    124 posts
    Member since:
    Feb 2011

    Posted 09 Jul 2015 Link to this post

    Thank doesn't seem to help.  The scenario is a large table that needs to be a bit squeezed onto the page.  Data with spaces in them should typically be wrapped first.

     Example of the problem with or without TableLayoutType.AutoFit set:

     

     

  4. Dan
    Dan avatar
    124 posts
    Member since:
    Feb 2011

    Posted 09 Jul 2015 in reply to Dan Link to this post

    Sorry - here is the attachment
  5. Nikolay Demirev
    Admin
    Nikolay Demirev avatar
    103 posts

    Posted 10 Jul 2015 Link to this post

    Hello Dan,

    I can suggest you to measure the text you want to set to a cell and then set the cell preferred width to the width of the text content. This way the width of the columns you want will be enough to show their values without the need to wrap the text. This can be done by finding the max width of the cells of the column and set the widths to the found max value. The following code snippet will help you achieve what you want:
    var table = new Telerik.Windows.Documents.Fixed.Model.Editing.Tables.Table();
     
    var row = table.Rows.AddTableRow();
     
    var cell = row.Cells.AddTableCell();
    var block = cell.Blocks.AddBlock();
    block.InsertText("1234");
     
    cell.PreferredWidth = block.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)).Width;

    I hope this works for you.

    Regards,
    Nikolay Demirev
    Telerik
Back to Top