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

Free Support Forum - aspose.com

RTL implementation and English Text

Hello,

We have implemented RTL to generate Arabic reports.

Issue is when English text comes with Arabic text, rather than showing the English text as it is, the sequence of letters in the word / sentence is changed.

See below the sample code.

// using Aspose.Words 9.0.0<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Document doc = new Document();

DocumentBuilder documentBuilder = new DocumentBuilder(doc);

XmlDocument XmlDoc = new XmlDocument();

string path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

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");

documentBuilder.ParagraphFormat.ClearFormatting();

documentBuilder.ParagraphFormat.Bidi = true;

documentBuilder.Font.Bidi = true;

documentBuilder.Font.NameBi = "Arial unicode MS";

documentBuilder.Font.SizeBi = 10;

documentBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

documentBuilder.InsertHtml("التقييم");

documentBuilder.InsertBreak(BreakType.LineBreak);

documentBuilder.InsertHtml("OPQ32i French v1");

documentBuilder.InsertBreak(BreakType.LineBreak);

documentBuilder.InsertHtml("OPQ32i French Professionals 1999");

doc.Save("Arabic&EnglishText.doc");

StartWord("Arabic&EnglishText.doc");

Problem: when OPQ32i French v1 and OPQ32i French Professionals 1999 is rendered on the word document the sequence of the letters are changed. Attached word output for your reference.

Required: English text should remain as it is which is not happening.

Regards,

Dwarika

Hi Dwarika,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I cannot reproduce the problem on my side. I use the latest version of Aspose.Words for testing. You can download it from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Also, I suppose, you should disable Bidi option before inserting LTR text:

Document doc = new Document();

DocumentBuilder documentBuilder = new DocumentBuilder(doc);

documentBuilder.ParagraphFormat.ClearFormatting();

documentBuilder.ParagraphFormat.Bidi = true;

documentBuilder.Font.Bidi = true;

documentBuilder.Font.NameBi = "Arial unicode MS";

documentBuilder.Font.SizeBi = 10;

documentBuilder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

documentBuilder.InsertHtml("التقييم");

documentBuilder.InsertBreak(BreakType.LineBreak);

// disable bidi option.

documentBuilder.Font.Bidi = true;

documentBuilder.InsertHtml("OPQ32i French v1");

documentBuilder.InsertBreak(BreakType.LineBreak);

documentBuilder.InsertHtml("OPQ32i French Professionals 1999");

doc.Save(@"Test001\Arabic&EnglishText.doc");

And one more thing, I think it is just mistake, but in your code you apply license after instantiating Document object. This is incorrect; you need to set the license before using any other Aspose.Words classes.

Best regards,

Hello Alexey,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your reply.

Following point will make you understand how we generate the reports,

  1. We generate reports in English (default language) content and then the English content is sent for translation.
  2. For any language, when suitable translation for a word / sentence (e.g. OPQ32i French Professionals 1999) is not available the contents remain in the original language i.e. English.
  3. We do not check the content at the time of generating reports.
  4. Since you have suggested disabling bidi property when English content needs to displayed, do you mean that it is not possible to display English content properly when Bidi property is set to true? Please confirm.

Regards,

Dwarika

Hi Dwarika,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Bidi option should be enabled to properly display RTL text. It should be disabled to properly display LTR text.

Best regards.