gfms
December 21, 2009, 10:56am
1
Hello,
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?
thanks
gfms
December 21, 2009, 11:00am
2
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?
example
$$Adress $$ -> 221b Baker Street \n London \n England (from above)
to
$$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
Hi
Thanks for your request. I think, in your case you should use ReplaceEvaluator:
https://reference.aspose.com/words/net/aspose.words/range/replace/
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,