Right to left languages problem

I have problems with the text in the document that is composed of right to left and left to right words. Can you please tell if this scenario is supported or not?

See attachments.

The first picture shows a document before aspose processing and after.

The second picture shows how VS see the text in word bookmark.

Hello

Thanks for your request. It seems you are using an old version of Aspose.Words. I cannot reproduce this problem on my side using the latest version of Aspose.Words (9.8.0).

I use the following code for testing:

Document doc = new Document(“BeforeAspose.doc”);

doc.Save(“out.doc”);

You can download the latest version from here:

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

Best regards,

I cant reproduce it in this way neither.

But when i do some processing to the document it happens.

We have a kind of map of all fields in the document. I am running through them and replace brackets for some of them.

foreach (Field wField in mDocumentMap.Fields)

{

#region Remove all delimiters and editors.

if (mDocument.Range.Bookmarks[“START” + wField.Id] != null)

{

if (wField.GetType() == typeof(UserInputField) && ((UserInputField)wField).Approved == true)

{

// No need to remove delimiters as the field was already approved.

}

else

{

if (!(wField is InternalField))

{

try

{

mDocument.Range.Bookmarks[“START” + wField.Id].Text = mDocument.Range.Bookmarks[“START” + wField.Id].Text.Replace("[", " “).Replace(”]", " ");

}

catch

{

}

}

}

}

}

After this code i am saving the document to the file and getting this problem.

Hello

Thank you for additional information. All that you need is using the following code:

Document doc = new Document(“C:\Temp\BeforeAspose.doc”);

doc.Range.Replace("[", " ", false, false);

doc.Range.Replace("]", " ", false, false);

doc.Save(“C:\Temp\out.doc”);

After this processing, there are no any brackets inside the output document.

I send the output document to your email.

Best regards,

Thank you.

Maybe it can be a solution but i am not sure that i can use this code because theoretically document may have a brackets that should not be removed. As i said before we need to remove brackets only from some kind of fields that we keep in our document map.

I also need to check that this code will not cause another problems.

Anyway maybe you can think about another solution or may be you are planning an update that will solve right to left issues?

Hello

Thanks for your inquiry. Actually there is no any problem with RTL.

Of course you can remove brackets from specific bookmarks only. Please see the following code:

Document doc = new Document(“C:\Temp\in.doc”);

// Bookmarks which contain brackets

Bookmark bk1 = doc.Range.Bookmarks[“START34634229519112559403F94”];

Bookmark bk2 = doc.Range.Bookmarks[“START35634229519343346561F95”];

Bookmark bk3 = doc.Range.Bookmarks[“START57634309578388128307F”];

Bookmark bk4 = doc.Range.Bookmarks[“START92634390078323432537F”];

bk1.Text = bk1.Text.Replace("[", " “).Replace(”]", " ");

bk2.Text = bk2.Text.Replace("[", " “).Replace(”]", " ");

bk3.Text = bk3.Text.Replace("[", " “).Replace(”]", " ");

bk4.Text = bk4.Text.Replace("[", " “).Replace(”]", " ");

doc.Save(“C:\Temp\out.doc”);

In case of using this code, all brackets inside specific bookmarks are replaced by empty string.

Please see the attached screenshot.

Best regards,

Thank you.

Thats what i do in my code (run through all bookmarks and removing brackets) but i had RTL problem that you dont have because i am replacing brackets also to the bookmark that doesnt have brackets (bookmark with right to left and left to right text together). Try to run replace to this bookmark and i assume you will get this problem too. I think there is a problem with RTL.

Hello

Thank you for additional information. I can suggest you two variants:

First one: check if a bookmark contains brackets:

Document doc = new Document(“C:\Temp\BeforeAspose2.doc”);

foreach (Bookmark bk in doc.Range.Bookmarks)

{

if (bk.Text.Contains("["))

bk.Text = bk.Text.Replace("[", " ");

if (bk.Text.Contains("]"))

bk.Text = bk.Text.Replace("]", " ");

}

doc.Save(“C:\Temp\out.doc”);

Second one: try using the following code:

foreach (Bookmark bookmark in doc.Range.Bookmarks)

{

Node curNode = bookmark.BookmarkStart;

while (curNode != null && !curNode.Equals(bookmark.BookmarkEnd))

{

//Move to next node

Node nextNode = curNode.NextPreOrder(doc);

//Check whether current contains end node

if (curNode.IsComposite)

{

if (!((CompositeNode)curNode).GetChildNodes(NodeType.Any, true).Contains(bookmark.BookmarkEnd) &&

!((CompositeNode)curNode).GetChildNodes(NodeType.Any, true).Contains(bookmark.BookmarkStart))

{

nextNode = curNode.NextSibling;

curNode.Range.Replace(new Regex("[\[\]]"), " ");

}

}

else

{

curNode.Range.Replace(new Regex("[\[\]]"), " ");

}

curNode = nextNode;

}

}

Best regards,