Table cell vertical alignment not applied consistently when converting DOCX to image

I’m seeing inconsistent rendering of table cell vertical alignment when converting DOCX to images with Aspose.Words.

  • sample1.docx → Cell content is not vertically centered in the PNG output (unexpected).
  • sample2.docx → Cell content is vertically centered (expected), but a warning is logged:
[MinorFormattingLoss] A table not supported by the new table layout logic is encountered.
Older logic that has known issues is applied.

Strangely, the document that falls back to the older table layout logic produces the expected result, whereas the one that appears to use the new table layout logic does not.

I cannot identify the reason for this difference from the document XML alone.

Sample Code

Environment:

  • .NET Framework 4.8
  • Aspose.Words 25.9.0
  • Microsoft Word 2010 (14.0.7268.5000, 32-bit)
using Aspose.Words;
using Aspose.Words.Saving;
using Aspose.Words.Tables;

new License().SetLicense(@"licensePath");

const string fileName = "sample2"; // sample1
const string docxPath = @"inputPath\" + fileName + ".docx";
WarningCollector.Clear();
var doc = new Document(docxPath)
{
    WarningCallback = new WarningCollector()
};
doc.UpdatePageLayout();

var tables = doc.GetChildNodes(NodeType.Table, true);
foreach (var node in tables)
{
    var table = (Table)node;
    for (var j = 0; j < table.Rows.Count; j++)
    {
        var row = table.Rows[j];
        for (var k = 0; k < row.Cells.Count; k++)
        {
            var cell = row.Cells[k];
            var format = cell.CellFormat;
            Console.WriteLine($"\n    --- Cell ({j + 1},{k + 1}) ---");
            Console.WriteLine($"      Vertical Alignment: {format.VerticalAlignment}");
            foreach (var node1 in cell.Paragraphs)
            {
                var paragraph = (Paragraph)node1;
                Console.WriteLine($"      Paragraph Alignment: {paragraph.ParagraphFormat.Alignment}");
            }
        }
    }
}


var saveOptions = new ImageSaveOptions(SaveFormat.Png)
{
    PageLayout = MultiPageLayout.Vertical(0)
};
doc.Save(@"outputPath\" + fileName + @".png", saveOptions);

var warnings = WarningCollector.GetWarnings();
if (warnings.Any())
{
    foreach (var w in warnings)
    {
        Console.WriteLine($"[{w.WarningType}] {w.Description}");
    }
}
else
{
    Console.WriteLine("(No warnings)");
}

public sealed class WarningCollector : IWarningCallback
{
    private static readonly List<WarningInfo> Warnings = [];

    public void Warning(WarningInfo info) => Warnings.Add(info);
    public static List<WarningInfo> GetWarnings() => [..Warnings];
    public static void Clear() => Warnings.Clear();
}

Attachments

Sample 1 docx:
sample1.docx (14.5 KB)
Aspose result (not vertically centered):


Expeceted result:

Sample 2 docx :
sample2.docx (15.5 KB)
Aspose Result (vertically centered (expected):

@SzuChiChen

It appears that the inconsistency in vertical alignment during the DOCX to image conversion with Aspose.Words may stem from differences in the table layout logic applied to your documents. The warning you received indicates that the new table layout logic encountered a table structure it does not fully support, resulting in a fallback to the older logic, which may handle certain cases differently.

To troubleshoot this issue, consider checking the following:

  1. Table Structure: Ensure that both tables in your documents have similar structures and properties.
  2. Cell Formatting: Verify that the vertical alignment settings are explicitly defined for all cells in both documents.
  3. Aspose.Words Version: Ensure you are using the latest version of Aspose.Words, as updates may address rendering issues.

If the problem persists, you may want to reach out to Aspose support with your specific documents for further assistance.

Best regards,
Professionalize.Discourse Bot

As noted, the document that falls back to the older table layout logic produces the expected result. I’d like to understand what triggers this warning and why the image layout differs between the two documents. It may be that some core table/page settings differ between them and I’ve missed those differences.

@SzuChiChen
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-28663

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as WORDSNET-28663) have been fixed in this Aspose.Words for .NET 25.10 update also available on NuGet.