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; }