try
<?php
require 'code128.php';
$data = ['item_name' => 'Fuel Vapour Hose'
,'code_purchase' => 'ABC-2342'
,'code_sale' => 'DFS-4312'
,'item_code' => '47900001'
];
class Barcode_Label extends PDF_Code128 {
protected $data;
//constructor
public function __construct()
{
parent::__construct('L','mm',[60, 35]);
}
public function printLabel($data)
{
$this->setMargins(5,5,5);
$this->SetAutoPageBreak(0);
$this->AddPage();
$this->setFont('Times', 'B', 10);
$this->Cell(50, 5, $data['item_name'], 0, 1, 'C');
$this->Cell(25, 5, $data['code_purchase'], 0, 0, 'C');
$this->Cell(25, 5, $data['code_sale'], 0, 1, 'C');
$barcode = $this->Code128( 5,15,$data['item_code'],50,10);
$this->setY(25);
$this->Cell(50, 5, $data['item_code'], 0, 1, 'C');
$this->ln(2);
}
} #Barcode_Label
$label= new Barcode_Label();
for ($i=0; $i<3; $i++) {
$label->printLabel($data);
}
$label->Output();
?>