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

Free Support Forum - aspose.com

Right to left languages work with some fonts and not others?

I am working on an application that can accept right to left language text from users (as html). We take this text and use the insertHtml functionality of Aspose.Words to create a Word doc from their text. There are a number of threads about this here already, but I’ve got some more questions.

Here is my sample code:

String hebrew = FileUtils.readFileToString(new File(“C:/Temp/Hebrew.txt”), “UTF16”);

Document doc = new Document();
DocumentBuilder docBuilder = new DocumentBuilder(doc);



docBuilder.getFont().setName(“Times New Roman”);


Unfortunately, I can’t actually embed the right to left text in the Java file so I copied “שלום רב שובך” into a text file which I open using the Apache-Commons FileUtils above.

In my example above, the text inserted with Arial has the words reversed, but the text with Times New Roman has the words in the correct order. I’m wondering why this is.

I know the recommended workaround around is to call docBuilder.getFont().setBidi(true), but that doesn’t work for us because we don’t know ahead of time which pieces of text will be bidi and which won’t and, even worse, we could have text that is mixed. Everything seems to work (even mixed text) as we’d like if we stick with Times New Roman, but switching to Arial gives a different result.

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

Thanks for your request. RTL is not supported upon using insertHtml method. Please use Write of WriteLine method. Please see the following link to learn how to insert RTL text into the document.


Best regards.