Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/08/2022 in all areas

  1. Beyond requinix's advice, https://github.com/barryvdh/laravel-debugbar is a popular package that helps with Laravel development.
    1 point
  2. Simple. Triple the page width and offset each label. 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',[190, 35]); } public function printLabel($data) { $this->setMargins(5,5,5); $this->SetAutoPageBreak(0); $this->AddPage(); $this->setFont('Times', 'B', 10); for ($lab=0; $lab<3; $lab++) { $offset = $lab * 65; $this->setXY($offset, 5); $this->Cell(50, 5, $data['item_name'], 0, 2, 'C'); $this->Cell(25, 5, $data['code_purchase'], 0, 0, 'C'); $this->Cell(25, 5, $data['code_sale'], 0, 2, 'C'); $barcode = $this->Code128($offset + 5,15,$data['item_code'],50,10); $this->setXY($offset, 25); $this->Cell(50, 5, $data['item_code'], 0, 1, 'C'); } } } #Barcode_Label $label= new Barcode_Label(); for ($i=0; $i<3; $i++) { $label->printLabel($data); } $label->Output(); [edit] PS I don't know your label dimensions so you may have to adjust offset, page size and margins
    1 point
  3. What you are doing is very confusing. Why are you not extending from the \PDF_Code128 class? Do you need the features of that class or not? Having code that both defines a class and also creates objects of that class is terrible. Have your class definition in a script with the name of the class as the name of the script. Then require that class in your script. As for the problem, it's shown to you clearly in the stack trace. You need to actually learn to look at it and follow it. FPDF is throwing the "No page has been added yet". You need to determine where in your code, that exception is occurring. The stack trace shows you that: $barcode = $pdf->Code128( 4,3,$data['item_code'],30,10); So this is the code that triggered your error -- and it's an object you try and create, purely so you can pass it into your class, yet don't even use in your code.
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.