Inserting newlines in Word using OpenXML

To insert newlines, you have to add a Break instance to the Run.

Example:

run.AppendChild(new Text("Hello"));
run.AppendChild(new Break());
run.AppendChild(new Text("world"));

The XML produced will be something like:

<w:r>
  <w:t>Hello</w:t>
  <w:br/>
  <w:t>world</w:t>
</w:r>

Leave a Comment