Horizontal alignment inverted in RTL text (arabic)

The paragraph horizontal alignment is not preserved in a Word generated using Aspose.Words.
The issue is that the text is aligned to the left even if I explicitly set it aligned to the right.

The code to reproduce the issue is:
var doc1 = new Document();

var paragraph = new Paragraph(doc1);
paragraph.ParagraphFormat.Alignment = ParagraphAlignment.Right;
paragraph.ParagraphFormat.Bidi = true;
var run = new Run(doc1) {Text = “سيب 321. شسي”};
paragraph.Runs.Add(run);
doc1.FirstSection.Body.AppendChild(paragraph);
doc1.Save(@“C:\Document.docx”, SaveFormat.Docx);

Regards,
Lucian Nistor
Senior .Net Developer
IBM Romania

Hi Lucian,


Thanks for your inquiry.

I have tested the scenario and have not found the shared issue while using latest version of Aspose.Words. It would be great if you please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate, how you want your final Word output be generated like. We will then provide you more information on this along with code.

Hi Tahir,

I’ve tested with the latest version - 13.7.0.0. The problem is present, the alignment is inverted.
In my scenario, I’m not using an existing Word file, I’m generating one using Aspose.Words.
The issue is simple. I want to set the alignment and RTL text direction for a paragraph, but if the text direction is RTL the alignment will be inverted (e.g. I set the alignment to right and in the generated word document it will be aligned to the left). Is this a feature, a know behavior.If it is please confirm so I can switch the alignment if I have a RTL paragraph.

Regards,
Lucian Nistor
Senior .Net Developer
IBM Romania

Hi Lucian,


Thanks for your inquiry. Yes, this is the expected paragraph’s alignment behavior for right-to-left text. If you check the OOXML version of output Docx, the value of w:jc element is ‘right’. Please see the attached image for detail.

Hope this answers your inquiry. Please let us know if you have any more queries.