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 :
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
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.
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 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.
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 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.
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 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.
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.
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)
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.
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.
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.
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)
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.
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.