So, I found the code that is ‘inserting’ the page break, but, I don’t know docx well enough to understand what it is doing. any pointers? this is the code:
private static void FixUpSectionProperties(WordprocessingDocument newDocument)
{
XDocument mainDocumentXDoc = newDocument.MainDocumentPart.GetXDocument();
mainDocumentXDoc.Declaration.Standalone = "yes";
mainDocumentXDoc.Declaration.Encoding = "UTF-8";
XElement body = mainDocumentXDoc.Root.Element(W.body);
var sectionPropertiesToMove = body
.Elements()
.Take(body.Elements().Count() - 1)
.Where(e => e.Name == W.sectPr)
.ToList();
foreach (var s in sectionPropertiesToMove)
{
var p = s.SiblingsBeforeSelfReverseDocumentOrder().First();
if (p.Element(W.pPr) == null)
p.AddFirst(new XElement(W.pPr));
p.Element(W.pPr).Add(s);
}
foreach (var s in sectionPropertiesToMove)
s.Remove();
}