No Wrap Equivalent?

7 posts, 0 answers
  1. Dan
    Dan avatar
    131 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
    136 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
    131 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
    131 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
    136 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
  6. Dima
    Dima avatar
    48 posts
    Member since:
    Feb 2012

    Posted 30 Apr in reply to Nikolay Demirev Link to this post

    It does not. Here you just shrink text. But how to prevent telerik from splitting words?

    like

    | Long text in Spread   |

    | sheet                         |

    need to be

    | Long text in               |

    | Spreadsheet             |

  7. Deyan
    Admin
    Deyan avatar
    158 posts

    Posted 03 May Link to this post

    Hello Dima,

    Words should be split only when the word is too long to fit in the available cell width. However, if the word width is smaller than the cell width and the word in not fitting in the current line, then the whole word should be moved to the next line. We have tried to reproduce the mentioned issue with the following code but without success.
    public RadFixedDocument CreateDocument()
    {
        RadFixedDocument document = new RadFixedDocument();
        FixedContentEditor editor = new FixedContentEditor(document.Pages.AddPage());
     
        Block word = new Block();
        word.InsertText("Spreadsheet");
        double wordWidth = word.Measure().Width;
     
        Table table = new Table();
        table.DefaultCellProperties.Borders = new TableCellBorders(new Border(), new Border(), new Border(), new Border());
        Block block = table.Rows.AddTableRow().Cells.AddTableCell().Blocks.AddBlock();
        block.InsertText("Long text in Spreadsheet");
        Size size = block.Measure();
        editor.DrawTable(table, size.Width - wordWidth / 2);
     
        return document;
    }

    You may see the attached PDF file which is the result from exporting the above-generated RadFixedDocument.

    Could you modify the above code so that it reproduces the mentioned issue?

    Regards,
    Deyan
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top