on-internet
← Community

Python-docx add_page_break is not visible in the document

Stack Overflow ·

I'm trying to write a document using python-docx library. I'm adding some simple text with and then I add page_break after each paragraph. Later on, I save and open the same file again. The page_breaks are not visible using "contains_page_break" property of paragraph. Is this a bug or am I missing something? sample code: from docx import Document from pathlib import Path if __name__ == "__main__": tmp_path = Path("../data") docx_path = tmp_path / "long_docx_with_breaks.docx" document = Document() for i in range(10): document.add_paragraph(f"This is paragraph {i + 1}.\n\n") if i % 2 == 1: # Add

Comments

Sign in or sign up to comment and upvote.

No comments yet.