Replace with multiple Lines (\n)


I try to search an replace different Texts in a Word-Document (.doc).

For that i Use Java 5 and Aspose.Words for Java 4 Beta(saveToPdf - Function is needed afterwards) \n has to be a new Line

For Example:

$$Name$$ -> Mr. Sherlock Holmes
$$Adress$$ -> 221b Baker Street \n London \n England

Theres no function in the DocumentBuilder like moveTo(TheStringIWantToMoveTo)

Also when i tried to use

doc.getRange().replace("$$*Adress*$$", "221b Baker Street \n London \n England", false, false);

Theire were no new Lines in the Document. Instead the new Lines were displayed as Squares in the Word-Document (see test_test.doc)

Do you have an Idea and maybe a Code-Sample how i could do that?


oh forgot to add

Is it also somehow Possible to Format the Replaced Text? Make Parte of it Bold, Larger or change the Color to Red?


$$Adress$$ -> 221b Baker Street \n London \n England (from above)
$$Adress$$ -> 221b Baker Street \n London \n England (or so)

Thougt it might be Possible to jump with the DocumentBuilder and use writeLine or so there and delete the $$***$$ and go somehow to the next place


Thanks for your request. I think, in your case you should use ReplaceEvaluator:
In ReplaceEvaluator you can use Documentbuilder, so you can specify formatting of the replacement.
Regarding \n characters, you can try replacing \n character in the replacement string with com.aspose.words.ControlChar.LINE_BREAK.
Best regards,