From be5a5f333b5db86212d32d01e80097e45b7058e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Po=C5=9Bpiech?= Date: Thu, 7 Mar 2019 10:27:47 +0100 Subject: [PATCH] Long table bugfix --- examples/LongTable.pdf | Bin 1242702 -> 459171 bytes lib/Layout/TableBox.php | 3 +++ lib/Layout/TableCellBox.php | 4 ++- lib/Layout/TableWrapperBox.php | 3 +++ lib/Page.php | 43 +++++++++++++++++++++++++++++---- 5 files changed, 47 insertions(+), 6 deletions(-) diff --git a/examples/LongTable.pdf b/examples/LongTable.pdf index 117a7d454adf9a439aeafa0847250741dc9be6ac..4b3c65de2a97ce83f5776a22f3c662818327580c 100644 GIT binary patch delta 1254 zcmbVL&ui2`6lM=yWwyK9j%{4a3MpC;#h967Ht|wVR{T+_Ui3+5%@Uz+}*Vs*Y3l1{gZYo@ClA3I` zDPl5C10i6X@ji4ie#$EgCZXmZpavanYrY4gjBne86&j@7(O7uQ&o=3~3Sk1jk9Y@X z2U?7Yj*OL7fzj#1PHt4_0;-_IP=k(~HR!?Hf}e)ZIlpCBz0fcFt02)di7{7IVwT|R z558ti)3Rvj MbCYds+}zpv1JK_-xiAL5eSh8aiMPBe9SO7l+kSrE#aNtzebKiYVpF#4m^vcsueVyt)cb}{4s=BWK z@TY(Kzx?-q{O|tN7s_K@{_J~y^Xc^i{x_`;j}PA-|J?8YoXh#o>HKFq|9Li>&t~mx z*3M?_Y}U?Z?dfc{ob8sg-Ey{D&UVY$Y(1N;XS4Neww}$_v)MM9J@x5tXS?lex1H^_ zv)z6Ux1Y`Sv)O(&+s|g@@oZNf&xTLs@oZWi&$i`}8W(C@&c>xs+d^#%wXM{)Qrmj8 z9nZg1YFw%DM2#nEJkh{Jo-$EeqEDHr?M!XwCmNVIRER`{SX78cg?LmN4NOET#H2!0 zDmO0m=U<3Th3Hg>PlX6oh*5=ajTx(dU~itu1e&pM6OEYszk0z>drP%3e&61VEXt*7zUsYI?y zs}i>=ajWj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XXufwHD3^0$_ zhHLRUT#IeEG?4-35!-NSDuX^o{LEt;F3n~DRIv@0<}>JH#50d=xHP2!P{lS}n$)0= z5zjof;nKVYKo#3?X=Z~yMm+O)9j?VTT$Wq729xW>VrN;{DzCy;nM5}Ko#3?Y5s#gMm+O)9d3zjxFxpX z(j*9&d2GX_X%PAt@$Wpg;nGY9Ko#3?X)c65Mm+P_hD*~S09CvWmnKB$W27@rQzE>_ zk)L!OZjEiYG%G?!70*1j;nKtiKo#3?X=;Q%Mm+P_hFjxvscCuy%p=|px5hTy8ryJb ziUiCfw&Btw34M(Cna4IMifyMUm!?ess@R5GV_#~TIRU6*8!pYA(8oya_BHmUrs)%aDz@R)cpWay zpwLmJJAT*LhD(zuyf0}Mh2A24=4l>2P{lS} znqZ-i5zjof;nExnKo#3?X_kdPMm+P_hD#GI099n&xBxs@R50voiEC;+e<3)HE>zP{lS}nwp`H5zjnchfA|F z099SJodp+!9N)P}vJX_fBLhR-~I6IFaP3)KY#h9-jlwi{}P90=N43)4zQA zom&_EqR;IH>~^0gn%n3fbE`l3pI`c4FZx6L^qlH-PUYvC(~tk_t6#n0!IZxCwasCut()) { + return $this; + } foreach ($this->getCells() as $cell) { $cell->measureHeight(); } diff --git a/lib/Layout/TableCellBox.php b/lib/Layout/TableCellBox.php index b65bda3..3c6288a 100644 --- a/lib/Layout/TableCellBox.php +++ b/lib/Layout/TableCellBox.php @@ -70,7 +70,9 @@ public function measureWidth() */ public function measureHeight(bool $afterPageDividing = false) { - //$this->applyStyleWidth(); + if ($this->wasCut()) { + return $this; + } foreach ($this->getChildren() as $child) { $child->measureHeight(); } diff --git a/lib/Layout/TableWrapperBox.php b/lib/Layout/TableWrapperBox.php index dee023f..79714d7 100644 --- a/lib/Layout/TableWrapperBox.php +++ b/lib/Layout/TableWrapperBox.php @@ -93,6 +93,9 @@ public function measureWidth() */ public function measureHeight(bool $afterPageDividing = false) { + if ($this->wasCut()) { + return $this; + } $maxHeight = '0'; foreach ($this->getChildren() as $child) { $child->measureHeight(); diff --git a/lib/Page.php b/lib/Page.php index 05fc70a..1144f93 100644 --- a/lib/Page.php +++ b/lib/Page.php @@ -1001,7 +1001,16 @@ public function cutBelow(Box $child, string $yPos) return $this; } - public function cutBox($box, $yPos, $cloned) + /** + * Cut box. + * + * @param Box $box + * @param string $yPos + * @param Box $cloned + * + * @return Box + */ + public function cutBox(Box $box, string $yPos, Box $cloned) { foreach ($box->getChildren() as $child) { if (!$child->isForMeasurement() || !$child->isRenderable()) { @@ -1032,7 +1041,7 @@ public function cutBox($box, $yPos, $cloned) * * @param Box[]|null $boxes * - * @return Box[] cloned boxes + * @return Box[]|null cloned boxes */ public function cloneAndDivideChildrenAfterY(string $yPos, array $boxes = null) { @@ -1053,7 +1062,7 @@ public function cloneAndDivideChildrenAfterY(string $yPos, array $boxes = null) $cloned->clearChildren(); $boxCoords = $box->getCoordinates(); if ($box instanceof TableWrapperBox && Math::comp($boxCoords->getY(), $yPos) <= 0 && Math::comp($boxCoords->getEndY(), $yPos) > 0) { - $cloned = $this->divideTable($box); + $cloned = $this->divideTable($box, $yPos, $cloned); } else { $cloned = $this->cutBox($box, $yPos, $cloned); } @@ -1062,16 +1071,40 @@ public function cloneAndDivideChildrenAfterY(string $yPos, array $boxes = null) return $clonedBoxes; } + /** + * Treat table like div? - just cut. + * + * @param TableWrapperBox $tableWrapperBox + * @param string $yPos + * + * @return bool + */ + public function treatTableLikeDiv(TableWrapperBox $tableWrapperBox, string $yPos) + { + $cells = $tableWrapperBox->getBoxesByType('TableCellBox'); + foreach ($cells as $cell) { + if (Math::comp($cell->getCoordinates()->getEndY(), $yPos)>0) { + return true; + } + } + return false; + } + /** * Divide overflowed table. * - * @param Box $tableChild + * @param Box $tableChild + * @param string $yPos + * @param Box $cloned * * @return TableWrapperBox */ - protected function divideTable(Box $tableChild) + protected function divideTable(Box $tableChild, string $yPos, Box $cloned) { $tableWrapperBox = $tableChild->getClosestByType('TableWrapperBox'); + if ($this->treatTableLikeDiv($tableWrapperBox, $yPos)) { + return $this->cutBox($tableWrapperBox, $yPos, $cloned); + } $pageEnd = Math::add($this->getDimensions()->getHeight(), (string) $this->margins['top']); if (Math::comp($tableWrapperBox->getCoordinates()->getY(), $pageEnd) >= 0) { // if table is below page do nothing - it will be moved to the next page and then again checked