The full picture is that I want to replace on a justified line a word with some content which contains line-brakes (is on multiple lines)
As a particular scenario I am replacing in a WORD-doc a key value (“test”) with a String (replacedDataDictionaryValue) which contains line-breaks (\r\n):
// just an example of input for replacement - you can take this String content from Input.docx
String replacedDataDictionaryValue = "text 1 long\r\n text\r\n second text\r\n";
//(1) check for LINE_BREAK (CR_LF) before replace - for Aspose special LINE_BREAK
replacedDataDictionaryValue = replacedDataDictionaryValue.replaceAll(ControlChar.CR_LF, ControlChar.PARAGRAPH_BREAK);
quoteDocument.getRange().replace("test", replacedDataDictionaryValue, false, false);
If I’m replacing ControlChar.CR_LF
(\r\n
) with ControlChar.PARAGRAPH_BREAK
(as suggested by you) I’m getting the same error which I’m getting on doc.getRange().replace(…)
if I’m not doing nothing for the replacedDataDictionaryValue
(still contains \r\n - and line bellow (1) is commented out)
Caused by: java.lang.IllegalArgumentException: The replace string cannot contain special or break characters.
at com.aspose.words.zzDO.setReplacement(Unknown Source)
at com.aspose.words.zzDO.(Unknown Source)
at com.aspose.words.zzDO.(Unknown Source)
at com.aspose.words.Range.replace(Unknown Source)
If I’m using ControlChar.LINE_BREAK for line (1) replacement for ControlChar.CR_LF
// check for LINE_BREAK (CR_LF) before replace - for Aspose special LINE_BREAK
replacedDataDictionaryValue = replacedDataDictionaryValue.replaceAll(ControlChar.CR_LF, ControlChar.PARAGRAPH_BREAK);
I’m getting the SHIFT+ENTER in the result word (without any error) but instead of correct formated content in the final word I’m having this problem with justified text for that inserted lines (which you can see in the attached zip - Result and ExpectedResult)
I haven’t written the java code but I expect to be clear enough from this message the scenario which I’m using (If you still need a exact Java.class I can provide one).
Is this covered somehow in the latest Aspose.Words for Java version?
Or can I have any solution for 14.4.0 Aspose version which I currently use?
Thank you and appreciate your support,
Horatiu