A hard page break will appear as an element <w:br>in the run ( <w:r>) element , something like this:
<w:p>
<w:r>
<w:t>some text</w:t>
<w:br w:type="page"/>
</w:r>
</w:p>
Thus, one approach would be to replace all of these occurrences with a distinctive line of text, for example, "{{foobar}}".
The implementation of this will be something like this:
from lxml import etree
from docx import nsprefixes
page_br_elements = document.xpath(
"//w:p/w:r/w:br[@w:type='page']", namespaces={'w': nsprefixes['w']}
)
for br in page_br_elements:
t = etree.Element('w:t', nsmap={'w': nsprefixes['w']})
t.text = '{{foobar}}'
br.addprevious(t)
parent = br.getparent()
parent.remove(br)
, - , , , docx. - lxml _Element.
, , , .