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

Free Support Forum - aspose.com

doc.Range.Replace loses line feed characters

I’m using doc.Range.Replace with some text that includes line feed characters (\n) and the resulting block of text in the Word document is all scrunched together, and is missing the new lines. How can I preserve the new lines?


If I do this to my string variable before calling doc.Range.Replace it seems fine:

text = Regex.Replace(text, @"\n", ControlChar.LineBreak);
Hi Marc,

Thanks for your inquiry. Please attach the following resources here for testing:

  • Your input Word document
  • Aspose.Words generated output document which shows incorrect result
  • Your expected document showing the correct result. You can create expected document using Microsoft Word.
  • Please create a standalone Console application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing..

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.

Best regards,