Reputation: 93
I am using the Novacode DocX c# library to create word documents and have run into a problem. I want my paragraphs to 'keep together' at page breaks. But, I also want to use soft returns to force my pictures to display vertically between lines of text.
So my question is, how do I add soft returns within paragraphs?
Upvotes: 9
Views: 1276
Reputation: 346
I solved this with:
using (DocX document = DocX.Create(@"docs\myDoc.docx"))
{
Paragraph p = document.Paragraphs[0];
p.Append("\u000D");
}
Note: this is adapted from @G.Dealmeida's answer. If you include the additional \u000A then you get a second line break.
Upvotes: 0
Reputation: 335
You can try to add one of those unicode char at the end of your paragraph, for instance :
using (DocX document = DocX.Create(@"docs\myDoc.docx"))
{
Paragraph p = document.Paragraphs[0];
p.Append("\u000D");
p.Append("\u000A");
}
Tell me if it solves your problem
Upvotes: 1