Skip to content

Commit

Permalink
Check page break
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Aug 27, 2024
1 parent 58de3e1 commit 160305e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0.75
8.0.76
2 changes: 1 addition & 1 deletion src/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ abstract class Base
/**
* TCPDF version.
*/
protected string $version = '8.0.75';
protected string $version = '8.0.76';

/**
* Time is seconds since EPOCH when the document was created.
Expand Down
9 changes: 6 additions & 3 deletions src/Tcpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -1125,9 +1125,12 @@ public function addTOC(
$region = $this->page->getRegion($pid);

if (($posy + $cellSpaceT + $cellSpaceB + $font['height']) > $region['RH']) {
$opage = $this->page->getNextRegion($pid);
$this->setPageContext($pid);
$pid = $opage['pid'];
$this->page->getNextRegion($pid);
$curpid = $this->page->getPageId();
if ($curpid > $pid) {
$pid = $curpid;
$this->setPageContext($pid);
}
$region = $this->page->getRegion($pid);
$posy = 0; // $region['RY'];
}
Expand Down
16 changes: 12 additions & 4 deletions src/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ public function addTextCell(
return;
}

if ($pid < 0) {
$pid = $this->page->getPageId();
}

if ($halign == '') {
$halign = $this->rtl ? 'R' : 'L';
}
Expand Down Expand Up @@ -478,7 +482,11 @@ public function addTextCell(
$cell['margin']['B'] = 0;

$this->page->getNextRegion($pid);
$this->setPageContext($pid);
$curpid = $this->page->getPageId();
if ($curpid > $pid) {
$pid = $curpid;
$this->setPageContext($pid);
}
}
}

Expand Down Expand Up @@ -1618,7 +1626,7 @@ public function defaultPageContent(int $pid = -1): string
$this->defaultfont = $this->font->insert($this->pon, 'helvetica', '', 10);
}

$region = $this->page->getRegion($pid);
$page = $this->page->getPage($pid);

// print page number in the footer
$out = $this->graph->getStartTransform();
Expand All @@ -1630,8 +1638,8 @@ public function defaultPageContent(int $pid = -1): string
$out .= $this->getTextCell(
(string) ($pid + 1),
$this->toUnit($this->defaultfont['dw']),
$region['RH'] - (2 * $this->toUnit($this->defaultfont['height'])),
$region['RW'] - (2 * $this->toUnit($this->defaultfont['dw'])),
$page['height'] - (2 * $this->toUnit($this->defaultfont['height'])),
$page['width'] - (4 * $this->toUnit($this->defaultfont['dw'])),
0,
0,
0,
Expand Down

0 comments on commit 160305e

Please sign in to comment.