FPDF Code128 Barcode Error

Asked

Viewed 94 times

-2

I am trying to generate a PDF file using FPDF and a class "Code 128 barcodes" (found in fpdf.org > scripts > Code 128 barcodes). The method Code128() is inside the archive Code128.php in class class PDF_Code128 extends FPDF

However, when I try to use my code I get error in the page that this method is already being used and I cannot generate PDF.

Follow my code until then:

require("../fpdf/fpdf.php");
require("../fpdf/code128.php");

$pdf=new PDF_Code128();
$pdf->AddPage("L", array(54,86));
$pdf->AddFont('Univers','','univers.php');
$pdf->SetAutoPageBreak(false);
$pdf->Image("../img/modeloArquivo.png", 0, 0, 86, 54);

$nome='Teste';
$pdf->SetFont('Univers', '', '6');
$pdf->SetXY(28.8,17);
$pdf->Write(6, $nome);

$local='Teste';
$pdf->SetFont('Univers', '', '6');
$pdf->SetXY(28.8,23);
$pdf->Write(6, $local);
  • Check the require of your file and the classes, it seems that the Pdf_code128 class extends the FPDF class and may be calling some method twice.

1 answer

-1

I checked what was put there in the comments and that’s exactly what solved. When I took the require("../fpdf/fpdf.php"); since file didn’t work either, but because I hadn’t seen the require in the file Code128.php. I updated the require in this file (by default it comes: require("../fpdf.php"); and on my website I am using require("../fpdf/fpdf.php");) and removed from my main file, leaving in it only the require("../fpdf/code128.php"); and stopped giving conflicts between the methods of Code128 and the FPDF.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.