Text Replace with RTL language

Hi

We have a word based text replace mechanism in our software.

The user creates a standard word document outside our software and upload it as a template.
The user is creating manually several text placeholder to be replace with a text in our software using aspose.words .net.

we have 2 problems that might have a single solution.

1.the user writes the replacement text placeholder , but it get spanned to a multiple text run (attached document named template.doc):
image.png (16.6 KB)

Those 2 highlighted texts are splitted to 3 text runs (2 XX and the middle with a number)

so we cant use text run replace , it wont find the whole XX12XX text.

So we try to use doc.Range.Replace.
It does replace the text, but its using the “latin text” font and not the hebrew/complex one :

image.png (14.4 KB)

So the replaced text is using “Arial” font and size instead of “David”.

Attached is the template.doc (inside zip)
template.zip (11.0 KB)

When using word automation on same document and doing replace ,
it replaces the whole XX12XX and using the font according to he new text language (if it is English letter , it uses the arial font , if Hebrew the david font in this case)

Please advice what should we do the get a similar behavior to the word replace text

@hagayg,

Thanks for your inquiry. Please share following resources as well, we will test the scenario at our end and will guide you accordingly.

  • Output document, showing unexpected behavior
  • Expected output, you may create it using MS Word
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

Best Regards,

Attached are source.zip which contains the source and doc template for a sample project.

source.zip (13.8 KB)

output.zip contains 3 doc files as result of different text replacment.
output.zip (6.1 KB)

1.SimpleReplace.doc the replaced text style is using the Latin font style.
2.ComplexReplace.doc replaced text style is o.k , but on office 2013/2016 the text is reserved (office 2010 and down seems o.k).
3.BidiComplexReplace.doc - replaced text style is o.k and in the correct order , on office 2013 the voucher number on top is reversed.

As mentiond in original post , method 1 seems the preferred way , but we need a way that the newly replaced text will use the correct formating (like word automation does)

Thanks

@hagayg

Thanks for sharing the additional information. After initial investigation, we have logged a ticket WORDSNET-15621 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.

Best Regards,

Hi

Its been almost a month.

Any update or estimate on when this issue is gonna get resolved ?

Even a workaround advice would be much helpful.

Thanks

@hagayg

Thanks for your inquiry. I am afraid your reported issue is still not resolved as our product team is busy in resolving other issues in the queue, reported earlier. However, we have recorded your concern and will notify you as soon as we made some significant progress towards issue resolution.

Thanks for your patience and cooperation.

Hi

I can see now that the issue is closed ? (WORDSNET-15621 ---- Status : Closed)

What does it means ?

Which of the scenarios is fixed ?
Which version the fix will be included in ?

Thanks.

@hagayg

Thanks for your inquiry. Your issue has been resolved and closed. Its fix will be available in September 2017 release of Aspose.Words for .NET i.e.17.9. However, we will notify you as soon it is published and gets available for download.

Thanks for your patience and cooperation.

Hi

Can you shed some light on what got fixed ?
In my post i included 3 scenarios , which one of them got fixed ?
Is it possible to get “early” beta of September release so i can verify it is working just fine.
We really don’t want to wait about 20 more days (usually the release is the middle of the month) and see its either not working good enough or there are some other problems (or in optimistic view it working just fine).

Thanks

@hagayg,

Thanks for your feedback. It is fix for the first method that you stated as preferred one.

Furthermore, I am afraid it is difficult to share a beta version of new release for testing. As it needs to follow complete procedure used for a regular release. Hopefully if everything goes as per plan then Aspose.Words for .NET 17.9 will be published in first week of September. However, meanwhile we are coordinating with our product team to get an expected fixed output document for reference.

Thanks for your patience and cooperation.

@hagayg,

The issues you have found earlier (filed as WORDSNET-15621) have been fixed in this Aspose.Words for .NET 17.9 update and this Aspose.Words for Java 17.9 update.

Thanks for the notification.

Indeed the the 17.9 version fixes the sample issue i posted , but after updating the DLL and using a temp license (our subscription expired few weeks ago) we encountered several places where the text replacement is working badly.

After long investigation we found that when the new text got spaces (maybe other chars too) the Latin style is kept the the two parts of the string are reversed in order.

Attached are new examples for the problem.

source.zip (14.5 KB)
Correct in page 2.png (1.8 KB)
incorrect in page 1.png (1.9 KB)
output.zip (2.2 KB)

Please fix it as soon as possible and please do give us beta version to check so we don’t have to wait for a monthly release to verify it is really fixed (our customers are growing impatience every day)

Hagay

@hagayg

Thanks for your feedback. We are looking into the scenario and will update you soon.

@hagayg

Thanks for your patience. We have tested the scenario and noticed the reported issue. We have logged a ticket WORDSNET-15869 in our issue tracking system for further investigation and rectification. We will keep you updated about the issue resolution progress within this forum thread.

@hagayg

Thanks for your patience. Our product team has investigated the issue and found it is not a bug of Aspose.Words but expected behavior. MS Word shows same behavior. We tried to replace “IIFirstNameII” with “מי יק” found that Word doesn’t mark new text with BiDi attribute.

However, if there is any difference in your issue and our understanding then please simplify the test case. You may leave only problematic text in source document and share an expected document created in MS Word using replace option for further investigation.

I don’t understand the your conclusion.

My test scenario clearly shows a bad and inconsistent result.

attached are 3 png files which shows output.

Word automation replace result for “מי יק” text (which is the expected behavior) :

word automation replace result.png (882 Bytes)

Aspose replace result when new text doesnt have a space in it (“מייק”) :

aspose replace result - no space in name.png (849 Bytes)

Aspose replace result when new text does have a space in it (“מי יק”) :

aspose replace result.png (925 Bytes)

1.The result and the second Aspose image is styled with the Latin style.
2.As stated in the post 2 weeks ago the text is reversed !!!

Please let me know if you need anything else in order to fix it quickly.

Hagay

@hagayg

We are sorry for the inconvenience. I am afraid the subjected language(RTL) is not our native language so we have troubles with issue understanding. As stated above, when we find and replace text with MS Word we get same results as Aspose.Words for .NET produces. So to simplify test, we will appreciate it if you please share an input document with only problematic text and also create and share an expected document with MS Word using find and replace option. It will help us to address your issue exactly.

Attached are 4 word files :

1.Template file with just the IIFirstNameII place holder

voucherTemplate.zip (10.0 KB)

2.Replace result with aspose when replacing with one word (no space) , good result with expected formatting/style. (using 17.9 version)

one word.zip (1.9 KB)

3.Replace result using aspose when replacing with two words (with space)
the first word is ראשון (hebrew for first) the second word is שני (hebrew for second) , as you can see the word שני is shown before the word ראשון and also latin style is used (font is different)

two words.zip (1.9 KB)

4.Replace using word replace as requested , the words is in the correct order (word ראשון is shown before word שני) and correct style/font is used.

two words word replace.zip (5.3 KB)

P.S : Earlier examples/attachments had more than one page , so maybe you missed the second page, this example contains only one word to be replaced as requested.

Code changes for earlier program to reproduce the scenario :

var license = new License();
        license.SetLicense(@"Aspose.Words.lic");

        var templateFields = new List<string> { "IILastNameII", "IIFirstNameII", "IIVoucherNumberII" };
        var valueFields = new List<List<string>>();
        valueFields.Add(new List<string> { "שון", "ראשון שני", "1345 67890" });
        valueFields.Add(new List<string> { "שון", "ראשון", "123456789" });          

Thanks for trying and please let me know if you need anything else.

Hagay

@hagayg

Thanks for providing the requested information. We have shared it with our product team for further investigation and we will notify you as soon as some update is available.

Hi

I see that WORDSNET-15869 is now marked as closed.

Is it fixed ?
If so will the fix be available in the next monthly release ?

Thanks

Hagay