Hi,
I have a problem with Zend_Pdf.
Should I create a table that has a barcode for each record. Studying the documentation I found this code:
private function generaBarcode($nrr) {
/*Barcode*/
$config = new Zend_Config ( array ('barcode' => 'code39', //EAN13
'barcodeParams' => array ('text' => $nrr ),
'renderer' => 'image',
'rendererParams' => array ('imageType' => 'jpeg' )
)
);
$renderer = Zend_Barcode::factory ( $config )->draw ();
$im = imagejpeg ( $renderer, "barcode.jpg", 50 );
$barcode = Zend_Pdf_Image::imageWithPath ( "barcode.jpg" );
return $barcode;
}
public function stampaBar() {
$server = "*.*.*.*";
$user = "LEONI";
$psw = "LEONILEONI";
$conn = i5_connect ( $server, $user, $psw );
$dollaro = chr ( 36 );
$lib = "A3" . $dollaro . "DB";
$sql = "select YLNRR
from $lib/YLDPHP9P
where YLSSRK=' '
order by YLNRR";
$result = i5_query ( $sql, $conn );
$pdf = new Zend_Pdf (); //Creiamo il documento PDF
$page = $pdf->newPage ( Zend_Pdf_Page::SIZE_A4 );
$y = 810;
$cont = 0;
while ( ($row = i5_fetch_assoc ( $result )) && ($cont<10) ) {
$barcode = $this->generaBarcode ( $row ['YLNRR'] );
$page->drawImage ( $barcode, 10, $y, 150, $y + 35 );
echo "Stampato il barcode $cont <br/>";
unlink ( "barcode.jpg" );
$y -= 80;
$cont ++;
}
$pdf->pages [] = $page;
$pdf->save ( "bar.pdf" );
i5_close ( $conn );
}
Using this code everything works but the time to create the pdf file is too big: 10 minutes for about 3000 records.
Can you help me how I can improve the time?
Thank you,
Fabio

