[MSWordUtils] NewLine() ignored in MSWord_ReplaceBookmarkWithText & MSWord_ReplaceBookmarksWithText
Forge component by Stuart Harris
Application Type
Traditional Web

Thank you very much for publishing this component, it is very useful in our project!

I run into one issue: Whenever I replace a bookmark with a text that contains a linebreak, it is ignored when the word document is generated (or actually it seems to be replaced by a space). Is there any solution fot this behaviour?

Hi Jarno,

Thank you for your question.

Text handling is certainly brittle with the underlying library.

However I checked and was able to make newlines appear in the document correctly.  I put new lines in this example and they were rendered correctly.

I hope this example helps.  If not, could you post with as much detail as possible and I will try to help.


Kind regards,

Stuart

Hi Stuart,

Thanks for your response.

So what I am doing seems to be exactly the same as your example. Find attached:

  1. The (simplified) word document that I am using; TestTemplate.docx. It has two bookmarks; "FullNames" and "FullAddress_MultiLine"
  2. A screenshot of the replacement of "FullAddress_MultiLine".
  3. A screenshot of the output of the document.

Thanks for your help!

Kind regards,

Jarno


TestTemplate.docx

Hi Jarno,

I'm not sure what the difference is.  I do know I have had trouble with the text handling in the library, so maybe it is not reliable.

The only other option is to use 2 bookmarks instead of one.

Kind regards,

Stuart

OK clear, I will indeed go for 2 bookmarks. Thanks!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.