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

Free Support Forum - aspose.com

Confused about table column fitting

Hi. I have the following sample code for constructing a document:

var document = new Document();
var builder = new DocumentBuilder(document);

builder.StartTable();

builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(50);
builder.Write(“0”);

builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(25);
builder.Write(“1”);

builder.InsertCell();
builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(25);
builder.Write(“2”);

builder.EndRow();

builder.EndTable();

This code works perfectly fine. It creates a table with three columns, the first column is twice as big as the second and the third. However, if I change the text in the second column to something like this:
builder.Write(“1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111”);
the result table will be completely ruined (see screenshot in attachments). I’ve found the way to make the table readable by setting Table.AllowAutoFit to false, but this suppresses all PreferredWidth settings.

Is there any way to display such table properly and preserve all PreferredWidth setting?

I am using Aspose Words for .NET 14.4.0.0.

Hi Artem,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If your create the table using MS Word with same contents, you will get the same output.

Please let us know if you have any more queries.