I am using this add on which helps me create different groups of pages. I have 2 major problems. First I am using PHP 7.3
and I don't want to use an older version of PHP
because I have other code that is working with PHP 7.3
. First problem comes on line 33 file - pagegroup.php:
$n = sizeof($this->PageGroups) + 1;
I am getting error
sizeof(): Parameter must be an array or an object that implements Countable
I tried to change this line with those code:
if (empty($this->PageGroups)) {
$n = 1;
} else {
$n = count($this->PageGroups)+1;
}
Can someone confirm me this is working fine, because my second problem is when I put this code:
require 'lib/pagegroup.php';
class MYPDF extends PDF_PageGroup {
function Header() {
$this->Cell(0, 6, 'Page '.$this->GroupPageNo().'/'.$this->PageGroupAlias(), 0, 0, 'C');
}
for ($i = 0; $i < 2; $i++) {
$pdf->StartPageGroup();
$pdf->AddPage();
// some other code ...
}
}
GroupPageNo is working great, but PageGroupAlias is returning {nb1}
and for group page 2 it is returning {nb2}
. So I end up having 1/{nb1}
and 1/{nb2}
and the final result should be 1/1
and 1/1
for example.
I manage to make it work under PHP 7.3. This is my working code inside method _beginpage I changed this line:
$n = sizeof($this->PageGroups)+1;
With those lines:
if (empty($this->PageGroups)) {
$n = 1;
} else {
$n = count($this->PageGroups) + 1;
}
Other most important thing is that it had to be set the font family to Arial other way it was not working and it was showing {nb2}
. So it should be something like that.
require 'lib/pagegroup.php';
class MYPDF extends PDF_PageGroup {
function Header() {
$this->AddFont('DejaVuSans', '', 'DejaVuSans.ttf', true);
$this->SetFont('Arial', '', 10);
$this->Cell(0, 6, 'Page '.$this->GroupPageNo().'/'.$this->PageGroupAlias(), 0, 0, 'C');
// change the font to the one you want to use in my case DajaVu
$this->SetFont('DejaVuSans', '', 16);
}
for ($i = 0; $i < 2; $i++) {
$pdf->StartPageGroup();
$pdf->AddPage();
// some other code ...
}
}