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

Free Support Forum - aspose.com

Braces switch possition in RTL text (arabic)

The text " ش(سيبشسي)ب" is not rendered correctly in a Word generated using Aspose.Words.
The generated texts is " ش(سيبشسي)ب

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;}

<![endif]–>". The braces are inverted.

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

var paragraph = new Paragraph(doc1);
paragraph.ParagraphFormat.Bidi = true;
var run = new Run(doc1) {Text = " ش(سيبشسي)ب"};
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. I suggest you, please use the Font.LocaleIdBi and Font.Bidi as shown in following code snippet. Hope this helps you.

Moreover, the Font.Bidi property specifies whether the contents of this run shall have right-to-left characteristics. The Bidi property, when on, shall not be used with strongly left-to-right text. Any behavior under that condition is unspecified. This property, when off, shall not be used with strong right-to-left text. Any behavior under that condition is unspecified.

When the contents of this run are displayed, all characters shall be treated as complex script characters for formatting purposes. This means that BoldBi, ItalicBi, SizeBi and a corresponding font name will be used when rendering this run.

DocumentBuilder builder = new DocumentBuilder();

// Signal to Microsoft Word that this run of text contains right-to-left text.
builder.Font.Bidi = true;

// Specify the font and font size to be used for the right-to-left text.
builder.Font.NameBi = "Andalus";
builder.Font.SizeBi = 48;

// Specify that the right-to-left text in this run is bold and italic.
builder.Font.ItalicBi = true;
builder.Font.BoldBi = true;

// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia.
// For the list of locale identifiers see http://www.microsoft.com/globaldev/reference/lcid-all.mspx
builder.Font.LocaleIdBi = 1025;


// Insert some Arabic text.
builder.Writeln(" ش(سيبشسي)ب");
builder.Document.Save(MyDir + "Font.Bidi Out.doc");

var doc1 = new Document();
var paragraph = new Paragraph(doc1);

paragraph.ParagraphFormat.Bidi = true;
var run = new Run(doc1) { Text = " ش(سيبشسي)ب" };
run.Font.NameBi = "Andalus";
run.Font.Bidi = true;

// Specify the locale so Microsoft Word recognizes this text as Arabic - Saudi Arabia.
run.Font.LocaleIdBi = 1025;
paragraph.Runs.Add(run);
doc1.FirstSection.Body.AppendChild(paragraph);

doc1.Save(MyDir + "out.docx", SaveFormat.Docx);

Hi Tahir,

Thank you for the quick reply.It was helpful but I have another problem right now.
In our application we’re taking content from an Excel file to build a Word file. Is there any possibility to obtain the BiDi font information from the Aspose.Cells.Font class, in order to pass them to the font property of the Word run object?

Regards,
Lucian Nistor
Senior .Net Developer
IBM Romania

Hi Lucian,

Thanks for your inquiry. The Aspose.Cells.Font have not Bidi property. However, I am moving this forum thread to Aspose.Total forum. My colleagues from Aspose.Cells team will reply you shortly about your query related right-to-left characteristics in Excel file.

Hi,

Thanks for your posting and using Aspose.Total.

We are afraid, there is no Bidi property in the Aspose.Cells.Font class, so you cannot retrieve Bidi information using Aspose.Cells.

Hi Mshakeel,

Can I find documentation about the BiDi properties of the Words Font Class?

Thank you in advance,
Lucian Nistor
Senior .Net Developer
IBM Romania

Hi Lucian,

Thanks for your inquiry. Please check the detail of Aspose.Words.Font class from here:

Please let us know if you have any more queries.