I’m converting a
document.docx (16.5 KB)
to HTML using Aspose.Words
for .NET. In the source document, I have a centered table that contains paragraphs which are explicitly left-aligned.
However, in the resulting HTML output, both the table and its inner paragraphs are rendered centered — the expected paragraph alignment (text-align: left;
) is not preserved.
To troubleshoot, I tried enforcing the alignment programmatically:
var tables = document
.GetChildNodes(NodeType.Table, true)
.OfType<Aspose.Words.Tables.Table>();
foreach (var tbl in tables)
{
tbl.Alignment = TableAlignment.Center;
foreach (var node in tbl.GetChildNodes(NodeType.Paragraph, true))
{
var p = (Paragraph)node;
p.ParagraphFormat.Alignment = ParagraphAlignment.Left;
}
}
Despite this, the generated HTML
html.docx (27.4 KB)
still centers both the table and its inner paragraphs.
Is there a recommended approach to ensure paragraph-level alignment is maintained correctly when converting to HTML?