Replace words in Microsoft Word document with a line break (carriage return) using Aspose.Words REST API

Hey Guys,

Is there a way to replace a value from a text with a line break/carriage return? Everytime I add a text to an word document, it ignores the new paragraphs, line breaks and carriage returns.

How can I solve it replacing a code value {{newline}} with an actual new line in word document?

Thanks!

@gbastian

I tried ReplaceText API method with the following request body parameter values and noticed it is adding a line break successfully. Please try it, it will help you to accomplish the task.

{
  "OldValue": "{{newline}}",
  "NewValue": "\r\n"
}

@tilal.ahmad

Before applying this replacetext, I’m trying to apply another replacetext with the code:

{ “OldValue”: “juris_{{158.field_2842_raw}}”,
“NewValue”: “{{158.field_2898}}”,
“IsMatchCase”: false,
“IsMatchWholeWord”: true,
“IsOldValueRegex”: true
}

But I’m getting this error:

{

“Error”: {

"Message": "After parsing a value an unexpected character was encountered: s. Path 'NewValue', line 2, position 676."

},

“RequestId”: “Root=1-605c70d2-6105be001705fe1612c2d410”

}

Can you please translate it to me? I have no idea what to do here…

@gbastian

Please share your sample input document here. We will try to replicate the issue at our end and investigate it.

A post was split to a new topic: How to replace text with bold text