I’m having a hard time figuring out this problem. I’m using the docx4j API to create some documents with several continuous section breaks in them. I can do this successfully, but the last section break in each document before the end of the document always shows up a next-page section break in Word. All the other continuous section breaks behave as expected, and it's always the very last section break that somehow converts into a next-page section break.
When I examine the document in the Word helper, this is what I see:
- Code: Select all
<w:document xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" xmlns:w16cid="http://schemas.microsoft.com/office/word/2016/wordml/cid" xmlns:w16se="http://schemas.microsoft.com/office/word/2015/wordml/symex" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" mc:Ignorable="w14 w15 w16se w16cid wp14">
<w:body>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>This is text under part 1.</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C"/>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>Part 1, Chapter 1</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>This is text under Part 1, Chapter 1.</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>This is text under Part 1, Chapter 1, Section 1</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C"/>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>This is text in Part 1, Chapter 1, Scene 1.</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>This is text in Part 1, Chapter 1, Scene 2.</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>before section break</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:pPr>
<w:sectPr w:rsidR="00EB730C" w:rsidSect="00EB730C">
<w:pgSz w:h="15840" w:w="12240"/>
<w:pgMar w:bottom="1440" w:footer="720" w:gutter="0" w:header="720" w:left="1440" w:right="1440" w:top="1440"/>
<w:cols w:space="720"/>
</w:sectPr>
</w:pPr>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>after section break</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>This is text under Part 2, Chapter 2.</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:br w:type="page"/>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C"/>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:rPr>
<w:b/>
</w:rPr>
<w:t>Part 2, Chapter 2</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>This is text under Part 2, Chapter 2</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>This is text under Part 2, Chapter 2, Section 1</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>This is text in Part 2, Chapter 2, Scene 1.</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>This is text in Part 2, Chapter 2, Scene 2.</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:r>
<w:t>before section break</w:t>
</w:r>
</w:p>
<w:p w:rsidP="00EB730C" w:rsidR="00EB730C" w:rsidRDefault="00EB730C">
<w:pPr>
<w:sectPr w:rsidR="00EB730C">
<w:type w:val="continuous"/>
<w:pgSz w:h="15840" w:w="12240"/>
<w:pgMar w:bottom="1440" w:footer="720" w:gutter="0" w:header="720" w:left="1440" w:right="1440" w:top="1440"/>
<w:cols w:space="720"/>
</w:sectPr>
</w:pPr>
</w:p>
<w:p w:rsidR="00000000" w:rsidRDefault="00EB730C">
<w:r>
<w:t>after section break</w:t>
</w:r>
</w:p>
<w:sectPr w:rsidR="00000000">
<w:headerReference xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId7" w:type="default"/>
<w:footerReference xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId8" w:type="default"/>
<w:pgSz w:code="1" w:h="15840" w:w="12240"/>
<w:pgMar w:bottom="1440" w:footer="720" w:gutter="0" w:header="720" w:left="1440" w:right="1440" w:top="1440"/>
<w:cols w:space="720"/>
</w:sectPr>
</w:body>
</w:document>
As far as I can tell, the last SectPr is correctly attached to a paragraph, is continuous, and comes before the final document-ending SectPr which is attached to the body.
I’ll attach an image of what it looks like in Word. The section break causes an unnecessary page break.
Any ideas about what is going on?
VIkram