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

Free Support Forum - aspose.com

Aspose Word paragraph direction

Hi Alexey,
Thanks for your quick reply & suggestion.
We are using Aspose word version
we are having one question regarding the text direction property available at pargaraph level in microsoft word.
When text is set to “right-to-left” for “Arabic” language this property must be set onto word document.
please refer the attached image"error.png" indicating the exact location of text direction at paragraph level.
Also refer the attched sample document "Sample.doc
" for further reference.
The sample code used to generate this document is as follows.

string path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
// Initialize Aspose license.
Aspose.Words.License lic = new Aspose.Words.License();
lic.SetLicense(path + @"\Aspose.Total.lic");
Aspose.Pdf.License lic1 = new Aspose.Pdf.License();
lic1.SetLicense(path + @"\Aspose.Total.lic");
Document doc = new Document();
DocumentBuilder documentBuilder = new DocumentBuilder(doc);
documentBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Right;
documentBuilder.Font.Bidi = true;

Will you please provide some more inputs on this issue?
Waiting for your reply…!!!
Thanks & Regards,

Hi Dwarika,

Thanks for your request. As I can see RTL text is inserted properly in the document you have attached. Please see the following link to learn how to insert RTL text:
Also there are Bidi properties In PageSetup of section:
In addition, why don’t you use DocumentBuilder.Write method, but use InsertHtml method to insert simple text?
Best regards.

Hi Alexey,
Thanks for your quick reply & suggestion.
The above threads give me some information regarding the BIDI property which we can set at pageSetup, ParagraphFormat, RowFormat level for RTL.
But we are sorry to say that our original question is still remained unanswerable!!!
We want to achieve the text direction property set to “Right-to-left” while printing document in Arabic language.
1> Whether Aspose supports setting the text direction for right-to-left?
2>If u can refer my sample code the bidi property set on paragraph level do not set the text direction.
3>Is there any other API or Property need to set to achieve above functionality?
4> Why we need to explicitly set the alignment as “right” in order to generate the right aligned text, where setting the bidi property the text alignment automatically set to right align?
Because in normal word document if we want to print any Arabic text then

1> The text direction is set to “right-to-left” due to which our text alignment is by default “right aligned”

2> Then based upon the requirement we can change the alignment as left,right,centre but my text direction will remain as it is.

In my sample code i am using documentBuilder.inserHTML() API

Because our original text is a combination of HTML tag so we want to ensure that the functionality must work with this API.
Waiting for your reply…!!!
Thanks & Regards,

Hi Dwarika,

Thanks for your inquiry.

  1. Yes, Aspose.Words supports setting text direction “Right-to-Left”. The links I provided in my previous answer provides code examples how you can achieve this.
  2. Here is proper code to insert RTL text. Please use the same code.
DocumentBuilder builder = new DocumentBuilder();
// Signal to Microsoft Word that this run of text contains right-to-left text.
builder.Font.Bidi = true;
builder.ParagraphFormat.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 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.

  1. No, there is no other API. The only property you need to use is Bidi property, as I mentioned earlier.
  2. InsertHtml will not work properly for RTL because Aspose.Words does not support text direction upon HTML import.

Best regards.

The issues you have found earlier (filed as 390) have been fixed in this update.