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

Free Support Forum - aspose.com

Table Cell Width

Hello,


I upgrated Aspose.PDF.dll from v15.7.0.0 to v16.2.0. As result I have issues with table cells.

Before I was able to create in the table row different count of cells with different width.
Right now I have issues with this (see attachments). Right now it works like HTML table. I can’t use code like this: documentBuilder.CellFormat.HorizontalMerge = CellMerge.Previous; It takes to much effort for me to rewrite all my code with CellMerge.

Maybe exists other ways of fixing this? Cell width was good for me.

Thanks.

Hi Bradley,


Thanks for your inquiry. Your issue relates to Aspose.Words, so I am moving your post to the Aspose.Words forum. My Colleagues from Aspose.Words will guide you appropriately.

We are sorry for the inconvenience caused.

Best Regards,
Hi Bradley,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the target Word file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.

Hello,


I added zip archive with doc files and test .NET projects.

ConsoleApplication0_15_7_0_0 and Test_15_7_0_0.doc - How it was before. (was good)
ConsoleApplication2_16_2_0_0 and Test_16_2_0_0.doc - How it works now.

Thanks,

Hi Bradley,

Thanks for sharing the detail. We would like to clarify a bit regarding horizontally merged cells. If you imagine first row with one wide cell and second row with two narrow cells, then looking at this document the cell in the first row will appear horizontally merged. But it is not a merged cell; it is just a single wide cell.


Another perfectly valid scenario is when the first row has two cells. First cell has CellMerge.First and second cell has CellMerge.Previous, in this case it is a merged cell. In both cases, the visual appearance in MS Word is exactly the same. Both cases are valid. If you want to work with merged cells, please read following documentation article.
Working with Merged Cells

You are creating table with wide cells. In your case, we suggest you please do not use Table.AutoFit method. If you want to set the table’s width, please use Table.PreferredWidth property as shown in following code example. We have attached output document with this post for your kind reference. Hope this helps you.

DocumentBuilder documentBuilder = new DocumentBuilder();<o:p></o:p>

Aspose.Words.Tables.Table table = documentBuilder.StartTable();

documentBuilder.InsertCell();

documentBuilder.CellFormat.Width = 100;

documentBuilder.Write("100 - ????");

documentBuilder.InsertCell();

documentBuilder.CellFormat.Width = 100;

documentBuilder.Write("100");

documentBuilder.InsertCell();

documentBuilder.CellFormat.Width = 100;

documentBuilder.Write("100");

documentBuilder.EndRow();

documentBuilder.InsertCell();

documentBuilder.CellFormat.Width = 200;

documentBuilder.Write("200");

documentBuilder.InsertCell();

documentBuilder.CellFormat.Width = 100;

documentBuilder.Write("100");

documentBuilder.EndRow();

table.PreferredWidth = PreferredWidth.FromPoints(300);

documentBuilder.EndTable();

documentBuilder.Document.Save(MyDir + "Test_16_2_0_0.doc");

Great. Solution with Table.PreferredWidth is better for me. Right now everything works well with doc but what about pdf? It works like before.


documentBuilder.Document.Save(MyDir + “Test_16_2_0_0.doc”);
documentBuilder.Document.Save(MyDir + “Test_16_2_0_0.pdf”);
Hi Bradley,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-13331. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.
Hi Bradley,

Thanks for your patience. This issue has been resolved in latest version of Aspose.Words for .NET 16.3.0. You just need to call Table.AutoFit(AutoFitBehavior.FixedColumnWidths) method after creating the table. Please use Aspose.Words for .NET 16.3.0. We have attached the output Pdf with this post for your kind reference.

DocumentBuilder documentBuilder = new DocumentBuilder();

Aspose.Words.Tables.Table table = documentBuilder.StartTable();

documentBuilder.InsertCell();

documentBuilder.CellFormat.Width = 100;

documentBuilder.Write("100 - ????");

documentBuilder.InsertCell();

documentBuilder.CellFormat.Width = 100;

documentBuilder.Write("100");

documentBuilder.InsertCell();

documentBuilder.CellFormat.Width = 100;

documentBuilder.Write("100");

documentBuilder.EndRow();

documentBuilder.InsertCell();

documentBuilder.CellFormat.Width = 200;

documentBuilder.Write("200");

documentBuilder.InsertCell();

documentBuilder.CellFormat.Width = 100;

documentBuilder.Write("100");

documentBuilder.EndRow();

table.PreferredWidth = PreferredWidth.FromPoints(300);

documentBuilder.EndTable();

// Update the table structure to match the specified cell widths.

table.AutoFit(AutoFitBehavior.FixedColumnWidths);

documentBuilder.Document.Save(MyDir + "Test_16_3_0_0.pdf");

The issues you have found earlier (filed as WORDSNET-13331) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.