Skip to content

[question] Can't find page breaks in an existing document #823

@giuliohome

Description

@giuliohome

I've tried to open an existing docx with the following code:

from docx import Document
document = Document('Testme.docx')
sections = document.sections
for section in sections:
    print(section.start_type)
paragraphs = document.paragraphs
for paragraph in paragraphs:
    for run in paragraph.runs:
        print(run.text)
        if hasattr(run, 'breaks'):
            for br in run.breaks:
                print(br.type.__name__)

The document has 3 pages (and here I mean 2 manual page breaks) but I can only see the initial NEW_PAGE (2) from the output.
Which is the correct show to find the page breaks?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions