I've tried with AliasNbPage() to get total pages of pdf. i do called '{nb}' to get total pages and it doesn't give output numbers instead of {nb}. there's another way to get total of pages ?
$tot = strval(explode('/', strval($this->pdf->PageNo().'/{nb}'))[1]);
$this->pdf->SetX(44);
$this->pdf->Cell(40,5,": ".$tot.' Pages',0,1);
//while i'm tried to convert the number to the text, it doesn't show.
$this->pdf->Cell(40,5,": ".numb_to_text(intval($tot)).' Pages',0,1);
function init_number($nilai) {
$nilai = abs($nilai);
$huruf = array("", "satu", "dua", "tiga", "empat", "lima", "enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
$temp = "";
if ($nilai < 12) {
$temp = " ". $huruf[$nilai];
} else if ($nilai <20) {
$temp = $this->init_number($nilai - 10). " belas";
} else if ($nilai < 100) {
$temp = $this->init_number($nilai/10)." puluh". $this->init_number($nilai % 10);
} else if ($nilai < 200) {
$temp = " seratus" . $this->init_number($nilai - 100);
} else if ($nilai < 1000) {
$temp = $this->init_number($nilai/100) . " ratus" . $this->init_number($nilai % 100);
} else if ($nilai < 2000) {
$temp = " seribu" . $this->init_number($nilai - 1000);
} else if ($nilai < 1000000) {
$temp = $this->init_number($nilai/1000) . " ribu" . $this->init_number($nilai % 1000);
} else if ($nilai < 1000000000) {
$temp = $this->init_number($nilai/1000000) . " juta" . $this->init_number($nilai % 1000000);
} else if ($nilai < 1000000000000) {
$temp = $this->init_number($nilai/1000000000) . " milyar" . $this->init_number(fmod($nilai,1000000000));
} else if ($nilai < 1000000000000000) {
$temp = $this->init_number($nilai/1000000000000) . " trilyun" . $this->init_number(fmod($nilai,1000000000000));
}
return $temp;
}
function numb_to_text($nilai) {
$nilai = (int) $nilai;
if($nilai<0) {
$hasil = "minus ". trim($this->init_number($nilai));
} else {
$hasil = trim($this->init_number($nilai));
}
return $hasil;
}
Add $pdf->AliasNbPages();
After $pdf->AddPage();