Skip to content

Commit 249412b

Browse files
Word2007 Reader: Support the page break (<w:lastRenderedPageBreak/>) (#2662)
Co-authored-by: stanolacko <[email protected]>
1 parent 89a202e commit 249412b

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

docs/changes/1.x/1.3.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Word2007 Writer: Support for field REF by [@crystoline](https://github.com/crystoline) in [#2652](https://github.com/PHPOffice/PHPWord/pull/2652)
1111
- Word2007 Reader : Support for FormFields by [@vincentKool](https://github.com/vincentKool) in [#2653](https://github.com/PHPOffice/PHPWord/pull/2653)
1212
- RTF Writer : Support for Table Border Style fixing [#345](https://github.com/PHPOffice/PHPWord/issues/345) by [@Progi1984](https://github.com/Progi1984) in [#2656](https://github.com/PHPOffice/PHPWord/pull/2656)
13+
- Word2007 Reader: Support the page break (<w:lastRenderedPageBreak/>) by [@stanolacko](https://github.com/stanolacko) in [#2662](https://github.com/PHPOffice/PHPWord/pull/2662)
1314

1415
### Bug fixes
1516

src/PhpWord/Reader/Word2007/AbstractPart.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,18 +236,21 @@ protected function readParagraph(XMLReader $xmlReader, DOMElement $domNode, $par
236236
$fontStyle = $this->readFontStyle($xmlReader, $domNode);
237237
$nodes = $xmlReader->getElements('w:r', $domNode);
238238
foreach ($nodes as $node) {
239-
$instrText = $xmlReader->getValue('w:instrText', $node);
240-
if ($xmlReader->elementExists('w:fldChar', $node)) {
241-
$fldCharType = $xmlReader->getAttribute('w:fldCharType', $node, 'w:fldChar');
242-
if ('begin' == $fldCharType) {
243-
$ignoreText = true;
244-
} elseif ('end' == $fldCharType) {
245-
$ignoreText = false;
246-
}
239+
if ($xmlReader->elementExists('w:lastRenderedPageBreak', $node)) {
240+
$parent->addPageBreak();
247241
}
242+
$instrText = $xmlReader->getValue('w:instrText', $node);
248243
if (null !== $instrText) {
249244
$textContent .= '{' . $instrText . '}';
250245
} else {
246+
if ($xmlReader->elementExists('w:fldChar', $node)) {
247+
$fldCharType = $xmlReader->getAttribute('w:fldCharType', $node, 'w:fldChar');
248+
if ('begin' == $fldCharType) {
249+
$ignoreText = true;
250+
} elseif ('end' == $fldCharType) {
251+
$ignoreText = false;
252+
}
253+
}
251254
if (false === $ignoreText) {
252255
$textContent .= $xmlReader->getValue('w:t', $node);
253256
}

src/PhpWord/Reader/Word2007/Document.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ private function readSectionStyle(XMLReader $xmlReader, DOMElement $domNode)
138138

139139
/**
140140
* Read w:p node.
141-
*
142-
* @todo <w:lastRenderedPageBreak>
143141
*/
144142
private function readWPNode(XMLReader $xmlReader, DOMElement $node, Section &$section): void
145143
{

0 commit comments

Comments
 (0)