Skip to content

Bug : XWPFRun loses <w:br> information; cannot distinguish page breaks from line breaks #1013

@SimonBach1

Description

@SimonBach1

Hello,

I’m running into an issue with XWPFDocument. In a .docx file:

Page breaks are represented in the XML as:

<w:r><w:br w:type="page"/></w:r>

Line breaks (manual line breaks, Shift+Enter) are represented as:

<w:r><w:br/></w:r>

However, after opening the document with XWPFDocument:

The corresponding XWPFRun for both types of breaks has run.getText() == "\n" and run.getCTR().getBrArray() is empty.

This means there is no way to distinguish a page break from a line break when using XWPFRun.

I would expect getBrArray() to contain the <w:br> elements with their type (page or default) so that page breaks can be detected programmatically.

Is this the intended behavior, or is there a way to preserve and distinguish page breaks in POI?

Thanks in advance,

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