We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to give New Line Character in word


I have used the following for find and replace

string address="Address1 Address2 Address3";

objWordDoc.Range.Replace(#Address#, address, false, false);

The result of above is like

Address1 Address2 Address3

But my requirement is like,the result should display like




Can i use any newline characters in the string "address",some thing like "\n" in .net .

ex: Address1\nAddress2\nAdress3

Or any other option to achieve my requirement


Ajeesh M J

Hi Ajeesh,

Thanks for your inquiry. In your case, I suggest you please implement IReplacingCallback Interface and use the following code snippet to achieve your requirements.

Moreover, please check the code examples shared at following documentation links for your kind reference. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "in.docx");

ReplaceTest obj = new ReplaceTest();

obj.relaceText = "Address1 Address2 Address3";

doc.Range.Replace(new Regex("#Address#"), obj, false);

doc.Save(MyDir + "out.docx");

private class ReplaceTest : IReplacingCallback


public string relaceText = "";

ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)


DocumentBuilder builder = new DocumentBuilder((Document)e.MatchNode.Document);


foreach (string address in relaceText.Split(new Char[] { ' ' }))




e.Replacement = "";

return ReplaceAction.Replace;