I am using tcpdf 6.2.13 to print mysql data into pdf format. I am creating custom index with school name and page number. For that i have fetched the mysql data in foreach loop and loading school id to store page number in mysql for that school.
Issue is using TCPDF to get the page number i am trying following code $pdf->getAliasNumPage() but when i try to store it in variable it shows empty.
Output: Day School{:pnp:}
If i remove exit and generate the pdf then it shows page number in pdf file like
Output: Day School 2
why $pdf->getAliasNumPage() showing {:pnp:} and not showing page number?
why it's value can not be stored in to variable or database?
Can anyone help me to get the page number in tcpdf to store in database? these function $pdf->getAliasNumPage() shows page number for pdf but when i pass it's value in mysql query or in variable it shows empty why?
Any help would be appreciated. Code:
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('School DB');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$PgNo= $pdf->getAliasNumPage();
$pdf->SetFont('dejavusans', '', 10);
$rlt = $this->db->query("SELECT `school_pageno`,`school_country_id`,`school_state_id`,`school_city_id` FROM `school` where `school_country_id` = 2 group by `school_state_id` order by `school_state_id` asc");
$schoolquery = $rlt->result_array();
foreach ($schoolquery as $key => $statevalue)
{
$html .= "<br/>". $statevalue['name'];
$pnom = $pdf->getAliasNumPage();
$this->db->where('school_id', $statevalue['id']);
$this->db->update('school', array('school_pageno' => $pnom));
}
//print_r($html);exit;
$pdf->writeHTML($html, true, false, true, false, '');
Page number value doesn't work it shows {:pnp:} if i enable print_r. please help!