This is a migrated thread and some comments may be shown as answers.

No Wrap Equivalent?

6 Answers 134 Views
PdfProcessing
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 08 Jul 2015, 04:25 PM
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?  

6 Answers, 1 is accepted

Sort by
0
Nikolay Demirev
Telerik team
answered on 09 Jul 2015, 12:50 PM
Hello Dan,

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

I hope this helps.

Regards,
Nikolay Demirev
Telerik
0
Dan
Top achievements
Rank 1
answered on 09 Jul 2015, 01:33 PM

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:

 

 

0
Dan
Top achievements
Rank 1
answered on 09 Jul 2015, 01:34 PM
Sorry - here is the attachment
0
Nikolay Demirev
Telerik team
answered on 10 Jul 2015, 12:37 PM
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
0
Dina
Top achievements
Rank 1
answered on 01 May 2017, 12:35 AM

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             |

0
Deyan
Telerik team
answered on 03 May 2017, 12:35 PM
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.
Tags
PdfProcessing
Asked by
Dan
Top achievements
Rank 1
Answers by
Nikolay Demirev
Telerik team
Dan
Top achievements
Rank 1
Dina
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or