Hi
Im trying to attach barcode image to pdf file, but strangely same image appears on every page although bcode string changes as wanted. Anyone knows whys that? I'll put one function that takes pdf file and barcode string as arguments.
- first delete old image
- initialize barcode
- collect image data to buffer
- write binary data to image file
- attach image source to pdf
- attach bar code string to pdf and return pdf
Should be straight forward...
Perhaps image content comes from cache? Anything to do with it?PHP Code:function setBarCode( $pdf, $bcode ) {
global $_x, $_y;
$img_src = 'code.png';
unlink( $img_src );
// MAKE BARCODE
$c = new Image_Barcode_code128();
$c->_barcodeheight = 83;
$c->_font = 3;
$c->_barwidth = 2;
ob_start();
$c->draw( $bcode, 'png', false );
$image_data = ob_get_contents();
ob_end_clean();
$fp = fopen( $img_src, 'wb');
fwrite( $fp, $image_data ) ;
fclose( $fp );
// ATTACH BARCODE TO PDF
$pdf->Image( $img_src, $_x+5, $_y+85 );
// print code
$pdf->SetFont( 'Arial', 'B', 9 );
$pdf->SetXY( $_x+55, $_y+76.7 );
$pdf->Cell( 100, 13, $bcode );
$pdf->SetXY( $_x+55, $_y+109.5 );
$pdf->Cell( 100, 13, $bcode );
return $pdf;
}
Well i tried this formula
but it didn't make the trick.Code:header( 'Cache-Control: no-cache, must-revalidate' ); header( 'Expires: '.gmdate( 'D, d M Y H:i:s', time() - 60*60*24*7 ).' GMT' ); header( 'Last-Modified: '.gmdate( 'D, d M Y H:i:s', time() ).' GMT' ); header( 'Content-Length: '.ob_get_length() );




Bookmarks