We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

AutoFitToWindow did break word in table header


I'm using Aspose.Words to create document with .dot template. In template I have all possible columns in GUI has checkboxes which columns want to show in generated document.
I send not checking columns to method, after removing columns I want to fit table to entire document width. All did ok, just not want to have word break in table header (see attached image). I show result in PDF.
Please help how can I set headers with minimum width for text length or break word after end - not in the middle?

Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
foreach (var columnHeader in TableColumnsForRemove)
int columnsCount = table.Rows[0].Cells.Count;
for (int x = 0; x < table.Rows[0].Cells.Count; x++)
if (table.Rows[0].Cells[x].Range.Text.ToString().StartsWith(columnHeader.ToString()))
Column column = Column.FromIndex(table, x);
if (column != null)

// Autofit the table to the page width.

I tried with PreferredWidth, but no success..

Hi Primož,

Thanks for your inquiry.

In case you’re using an older version of Aspose.Words, I would suggest you please upgrade to Aspose.Words 13.5.0 from the following link:

Secondly, if the problem still remains, please create a simple application (for example a Console Project) that helps us reproduce the same problem on our end and attach it here for testing. Unfortunately, it is difficult to say what the problem is without the document(s) and simplified application. We need your input/output document(s) and simple project to reproduce the problem. As soon as you get these pieces of information to us we’ll start our investigation into your issue and provide you more information.

Best regards,