Hi,
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);
builder.moveTo(run);
builder.getCurrentParagraph().getParagraphFormat().setBidi(false);
builder.getFont().setLocaleId(1033);
String fontName = “Times New Roman”;
builder.getFont().setNameBi(fontName);
builder.getFont().setNameFarEast(fontName);
builder.getFont().setName(fontName);
builder.getFont().setBidi(false);
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++) {
paragraph.getChildNodes().removeAt(1);
}
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?
Thanks,
Zeljko