We have using Aspose.Words.jdk16-14.1 jar and IReplacingCallback() { replacing(ReplacingArgs) for replacing the content of IF clause merge field with following word template/mail-merge field texts:
<IF:«field1»<>@«field1»>
<IF:«field2»<>@«2»>
Above operation works fine incase we have only one IF clause above but in case we have more than one as the case above it fails with “String index out of range: -38”.
.println(“MERGEFIELD contained in IF clause.” + text1);
return 1;
}
try {
arg0.setReplacement(text2);
} catch (Exception e) {
System.out
.println(“Postprocessing error. Replacing text in:” + text2);
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
}, true);
} catch (Exception e1) {}
Similar code worked for us to override the "ReplaceEvaluator-> replace(Object arg0, ReplaceEvaluatorArgs arg1){…} with old version of Aspose "Aspose.Words.jdk15-2.4.2 jar"
I have observed the issue shared by you and it seems to be an issue related to Aspose.Words. I am moving this thread to Aspose.Words forum where our respective support team will assist you further in this regard.
Thanks for your inquiry. This issue does not occur if you use backward evaluation instead of forwards in your code. This is just a matter of changing the third parameter of the replace method to false. Generally, it is recommend if you are modifying the document in a custom replacement evaluator then you should use backward replacement.
Thanks for your inquiry. We are in coordination with product team to get answer pertaining to your queries. Soon you will be updated with the required information.
The isForward parameter indicates whether the find and replace will be performed in forward or backward direction inside the Root Node. Default is false!
We need this parameter only upon using custom ReplaceEvaluator, to avoid problem with node indexes. So you have to use False (Default) if you are going to change nodes in any way using ReplaceEvaluator.
You can use True if you need to replace for example only the first occurrence of searched word.
Hope, this helps.
Best regards,
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.