Skip to content

Commit

Permalink
Word2007 Reader: Support the page break (<w:lastRenderedPageBreak/>) (#…
Browse files Browse the repository at this point in the history
…2662)

Co-authored-by: stanolacko <[email protected]>
  • Loading branch information
Progi1984 and stanolacko authored Aug 28, 2024
1 parent 89a202e commit 249412b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/changes/1.x/1.3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Word2007 Writer: Support for field REF by [@crystoline](https://github.com/crystoline) in [#2652](https://github.com/PHPOffice/PHPWord/pull/2652)
- Word2007 Reader : Support for FormFields by [@vincentKool](https://github.com/vincentKool) in [#2653](https://github.com/PHPOffice/PHPWord/pull/2653)
- 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)
- Word2007 Reader: Support the page break (<w:lastRenderedPageBreak/>) by [@stanolacko](https://github.com/stanolacko) in [#2662](https://github.com/PHPOffice/PHPWord/pull/2662)

### Bug fixes

Expand Down
19 changes: 11 additions & 8 deletions src/PhpWord/Reader/Word2007/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,21 @@ protected function readParagraph(XMLReader $xmlReader, DOMElement $domNode, $par
$fontStyle = $this->readFontStyle($xmlReader, $domNode);
$nodes = $xmlReader->getElements('w:r', $domNode);
foreach ($nodes as $node) {
$instrText = $xmlReader->getValue('w:instrText', $node);
if ($xmlReader->elementExists('w:fldChar', $node)) {
$fldCharType = $xmlReader->getAttribute('w:fldCharType', $node, 'w:fldChar');
if ('begin' == $fldCharType) {
$ignoreText = true;
} elseif ('end' == $fldCharType) {
$ignoreText = false;
}
if ($xmlReader->elementExists('w:lastRenderedPageBreak', $node)) {
$parent->addPageBreak();
}
$instrText = $xmlReader->getValue('w:instrText', $node);
if (null !== $instrText) {
$textContent .= '{' . $instrText . '}';
} else {
if ($xmlReader->elementExists('w:fldChar', $node)) {
$fldCharType = $xmlReader->getAttribute('w:fldCharType', $node, 'w:fldChar');
if ('begin' == $fldCharType) {
$ignoreText = true;
} elseif ('end' == $fldCharType) {
$ignoreText = false;
}
}
if (false === $ignoreText) {
$textContent .= $xmlReader->getValue('w:t', $node);
}
Expand Down
2 changes: 0 additions & 2 deletions src/PhpWord/Reader/Word2007/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ private function readSectionStyle(XMLReader $xmlReader, DOMElement $domNode)

/**
* Read w:p node.
*
* @todo <w:lastRenderedPageBreak>
*/
private function readWPNode(XMLReader $xmlReader, DOMElement $node, Section &$section): void
{
Expand Down

0 comments on commit 249412b

Please sign in to comment.