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

Free Support Forum - aspose.com

Text direction problem (4725)


I have a Word document containing text written in Urdu language. When I add some English text in the same paragraph where Urdu text was and then delete all the runs containing Urdu text, first part of the added English text is written in right-to-left direction. Please see the attached screenshot for your reference.

Here’s the code I use:

Document document = new Document(“Power Play_UR.docx”);

DocumentBuilder builder = new DocumentBuilder(document);

NodeCollection paragraphs = document.getChildNodes(
NodeType.PARAGRAPH, true);

Paragraph paragraph = (Paragraph) paragraphs.get(1);

Run run = (Run) paragraph.getChildNodes().get(0);



String fontName = “Times New Roman”;



builder.write(“‎‎Arshad Sharief: Greetings from Arshad Sharief to the millions in Pakistan and across the world. Dear audience! Pakistan is a wonderful country where you can do money laundering if you launder enough money, even if it amounts to millions and billions of Rupees, nobody can question you. NROs come in the country, and after it all matters come to an end. The trials keep going for years in the courts, and they say go to the court and prove it. But there are some cases when money trail reaches you, then you admit to it. You say, yes it is mine. You have kept denying. One of the best examples of this is former President Mr. Asif Zardari. During the entire reign of Pakistan People’s Party, he kept denying Rokwood Estates which is also known as Surrey Mansion. Present Prime Minister His Excellency Honourable Prime Minister Nawaz Sharief, when he was in opposition, used to say that he would bring back all this money. And he also use to say that if he could not bring it back, one can change his name. Come let’s have a look to remind ourselves as to what Mr. Nawaz Sharief had said about Surrey Mansions.‎‎”);

for (int i = 0; i < 31; i++) {

document.save(“Power Play_UR-xx.docx”);

I tried with both Aspose.Words for Java 16.11.0 and 16.12.0.

Can you check this?


Hi Zeljko,

Thanks for your inquiry. After an initial test with Aspose.Words for Java 16.12.0, we were unable to reproduce this issue on our end (see attachments).

Do you see the same problem when converting to PDF? Also, please attach these output documents i.e. the PDF and the “Power Play_UR-xx.docx” file for further testing. What are your MS Word, Java and OS versions?

Best regards,

Hi Awais,

I attached the output documents you need.

There’s no issue when I save the file as PDF. Also, if I open the file you generated - awjava-16.12.0.docx - with Word 2013, I can still see the text written in wrong direction. But if I open with Word 2016, both yours and my generated file look fine.

Here’s the environment info:

Microsoft Word 2013 15.0.4420.1017

java version "1.8.0_101"
Java™ SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot™ 64-Bit Server VM (build 25.101-b13, mixed mode)

OS Ubuntu 14.04 LTS 64bit


Hi Zeljko,

Thanks for your inquiry. For the sake of any correction, we have logged this problem in our issue tracking system as WORDSJAVA-1474. Our product team will further look into the details of this problem and we will keep you updated on the status of this issue. We apologize for your inconvenience.

Best regards,

Hi Zeljko,

Unfortunately, we are not able to reproduce this issue on our end. We tried the following options recently without any luck:

  • Generate files in Java and .NET,
  • Generate files in Windows and Ubuntu
  • Open with MS Word 2013 and MS Word 2016
  • Use Aspose Words 16.11.0, 17.2.0

Could you please provide more details? For example, generate this file using another machine?

Best regards,