Tengo el siguiente problema:
Genero un pdf y muestro unos valores para cada cliente, cada cliente tendria que ser mostrado en una hoja, creo que mi error esta al usar el stream y newpage, al filtrar segun consumo y ejecutarse el if solo me muestra ese, probe a que despues de cada posible caso me inserte una hoja y al final del bucle me haga stream... pero no lo logro....
Código PHP:
while($res = mysqli_fetch_array($result)){
//Generamos PDF
$pdf = new backgroundPDF('a4', 'portrait','image', array('img' => 'fondo2.jpg'));
$pdf->selectFont('Helvetica.afm');
$datacreator = array (
'Title'=>'',
'Author'=>'',
'Subject'=>'',
'Creator'=>'',
'Producer'=>''
);
$pdf->setLineStyle(0.5,'round');
$pdf->ezSetY(814);
$pdf->ezText("DATOS DEL CONTRATO",9,array('justification'=>'right'));
$pdf->ezSetY(800);
$pdf->addText(370,790,8,'Num.contrato');
$pdf->ezText("$contrato",8,array('justification'=>'right'));
$pdf->line(565,789,370,789);
//$pdf->ezSetY(790);
$pdf->addText(370,780,8,'Titular');
$pdf->ezText("$nom $ape",8,array('justification'=>'right'));
$pdf->line(565,779,370,779);
$pdf->ezSetY(780);
$pdf->addText(370,770,8,'NIF abonado');
$pdf->ezText("$nif",8,array('justification'=>'right'));
$pdf->line(565,769,370,769);
$pdf->ezSetY(770);
$pdf->addText(370,760,8,'Dirección');
$pdf->ezText("$dir",8,array('justification'=>'right'));
$pdf->line(565,759,370,759);
$consumo = ($res['lec_act'] - $res['lec_ant']); // CONSUMO
if ($consumo <= 18){
$pdf->addText(75,448,8,"1r TRAMO");
$pdf->addText(230,448,8,"$consumo");
$pdf->addText(311,448,8,"$pcan1");
$pdf->addText(414,448,8,"$totc1");
$pdf->addText(511,448,8,"$ivacan");
//ob_end_clean();
//$pdf->ezStream();
//$pdf->ezNewPage();
}
elseif (($consumo > 18) AND ($consumo <= 30)){
$pdf->addText(190,548,8,"Tramo 1 (18)");
$pdf->addText(311,548,8,"$pst1");
$pdf->addText(414,548,8,"$tot1");
//ob_end_clean();
//$pdf->ezStream();
}
elseif (($consumo > 30) AND ($consumo <= 36)){
$pdf->addText(190,548,8,"Tramo 1 (18)");
$pdf->addText(311,548,8,"$pt1");
$pdf->addText(414,548,8,"$tot1");
//ob_end_clean();
//$pdf->ezStream();
}
else{
$pdf->addText(190,548,8,"Tramo 1 (18)");
$pdf->addText(311,548,8,"$pt1");
$pdf->addText(414,548,8,"$tot1");
//ob_end_clean();
//$pdf->ezStream();
}
//ob_end_clean();
}
$pdf->ezStream();
?>
GRACIAS!