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

Free Support Forum - aspose.com

Text of Table Cell does not Wrap in DOCX | Optimize Document to MS Word Version using .NET

Hi,

I created document with table. First cell contains CellFormat.WrapText with false value. Both cells have preferred width 50% and table has preferred width 100%. When document is saved to docx both cells doesn’t wrap. When document is saved to pdf both cells is wrap.

See the sample program:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

var table = builder.StartTable();

var cel1 = builder.InsertCell();
cel1.CellFormat.WrapText = false;
builder.Write("Text Text Text Text Text Text Text Text Text Text");
cel1.CellFormat.PreferredWidth = PreferredWidth.FromPercent(50);

var cel2 = builder.InsertCell();
cel2.CellFormat.PreferredWidth = PreferredWidth.FromPercent(50);
builder.Write("Text Text Text Text Text Text Text Text Text Text");

table.PreferredWidth = PreferredWidth.FromPercent(100);

doc.Save(@"Test.docx");
doc.Save(@"Test.pdf");

We’re using Aspose.Words for .Net v21.6.0.

Thanks,
Monika

@acturisaspose

Please note that Aspose.Words mimic the behavior of MS Word 2019 when you save the document to PDF. You can get the same output for DOCX using following code snippet.

doc.CompatibilityOptions.OptimizeFor(MsWordVersion.Word2019);
doc.Save(MyDir + @"Test.docx");
doc.Save(MyDir + @"Test.pdf"); 

Thank you. I have the same output in word like in pdf and cell in table is wrap in both document. I want pdf have the same output like word. In meantime I found ticket:


So I will be waiting for this fix.

Thanks,
Monika

@acturisaspose

We will inform you via your other thread when the fix of WORDSNET-21289 is available.