space in right to left languages in a word file c#

506 views Asked by At

I'm working on a C# software, it generates some texts in a right to left language(persian). I use code below:

s += char.ConvertFromUtf32(32);

to add a space between words and at the end of the whole procedure, I will save the doc file. Although the saved text is looking good, but the space character is not a right to left space and make some problems like bad placed dots.like picture:

bad placed dots

I can fix it by replacing all the spaces in the saved file with changing the keyboard language to farsi and then type space. which makes th example like below:

changing the keyboard language to farsi and then type space

I have extracted the persian space char by using the following code which is 32.

char[] arr=s.ToCharArray();    

and the space char is 32. so, please help me how can I fix it.

1

There are 1 answers

0
FarZad On

actually, I found the answer. I used Spire.Doc to simplify the process of making word files, adding this line of code will make it completely correct.
TextRange tr = paragraph.AppendText("Spire.Doc"); tr.CharacterFormat.Bidi = true;
Thnx u guys for your help.