TableAlignment.Left is Misaligning a Row

Run the following code against the attached document. Note how one of the rows ends up misaligned.

Dim mylicense As New License

mylicense.SetLicense(“Aspose.Words.lic”)
doc = New Document(System.IO.Path.GetFullPath(“C:\InCaption.dot”))
bldr = New DocumentBuilder(doc)

bldr.MoveToBookmark(“StartSigBlock”)
Dim myTable As Table = bldr.CurrentParagraph.GetAncestor(NodeType.Table)
myTable.Alignment = TableAlignment.Left
doc.Save(“C:\InCaption.doc”)
Process.Start(“C:\InCaption.doc”)

We are running version 11.1.

Hi Steve,


Thanks for your inquiry. I am afraid, I was unable to find any difference when setting Table Alignment to Left with MS Word and when setting via Aspose.Words. It would be good if you could give a comparison as to how you are expecting your table to be rendered like (even a screenshot of the output will suffice).

Best Regards,

See the attached before and after screen shots. The 4th row in the table is out of alignment after doing a mytable.Alignment TableAlignment.Left.

Hi Steve,


Thanks for the additional information. In your case, clearing the row formatting will do the trick. Please try using the following code snippet as a work around:

Dim doc As New Document(“C:\temp\InCaption.dot”)
Dim bldr As New DocumentBuilder(doc)

bldr.MoveToBookmark(“StartSigBlock”)
Dim myTable As Table = bldr.CurrentParagraph.GetAncestor(NodeType.Table)

myTable.Alignment = TableAlignment.Left

For Each r As Row In myTable.Rows
r.RowFormat.ClearFormatting()
Next

doc.Save(“C:\temp\InCaption.doc”)
Process.Start(“C:\temp\InCaption.doc”)

I hope, this will help.

Best Regards,

That took care of the row alignment, but the heights got reset - for example, the second row must remain the height that it is.

Hi Steve,


Thanks for your inquiry. In this case, you can preserve the row height by using the following code:

Dim doc As New Document(“C:\temp\InCaption.dot”)
Dim bldr As New DocumentBuilder(doc)

bldr.MoveToBookmark(“StartSigBlock”)
Dim myTable As Table = bldr.CurrentParagraph.GetAncestor(NodeType.Table)

myTable.Alignment = TableAlignment.Left

For Each r As Row In myTable.Rows
Dim height As Double = r.RowFormat.Height
r.RowFormat.ClearFormatting()
r.RowFormat.Height =
height
Next

doc.Save(“C:\temp\InCaption.doc”)
Process.Start(“C:\temp\InCaption.doc”)

Best Regards,

That fixed it. Thanks.