I have text placeholders like [[Page_Break]] all over my document. And I would like to replace all these occurrences with real page breaks.
I came up with this extension method so far:
- Code: Select all
public static Document ReplaceWithPageBreak(this Document me, string placeholder)
{
if (me == null)
return null;
if (string.IsNullOrEmpty(placeholder))
return me;
var paragraphs = me.GetParagraphs(searchTag: placeholder);
foreach (var paragraph in paragraphs)
{
paragraph.AppendBreak(breakType: BreakType.PageBreak);
}
return me;
}
// in my main code
myDocument.ReplaceWithPageBreak("[[Page_Break]]")
This code sets the page breaks perfectly, but the [[Page_Break]] placeholders are still shown. What do I need to do, to delete these placeholders?
Thx,
Ingmar