I am using a barcode generator php code to generate barcodes. But when I want to write barcode to an existing pdf file using fpdi+fpdf the written string is not the generated barcode! It is written obscure words. The code that I used is below:
<?php
session_start();
#----- gets serialnumber from page form ------
$serialnumber = $_SESSION['serialnumber'];
#---------------------------------------------
include 'lib/barcode/barcode128.php';
$bar_code= bar128($serialnumber);
#echo $serialnumber;
include('lib/FPDI-2.3.6/src/autoload.php');
require('lib/fpdf184/fpdf.php');
require('lib/FPDI-2.3.6/src/fpdi.php');
$pdf = new Fpdi();
#$pdf->AddPage();
$pagecount= $pdf->setSourceFile("lib/test3.pdf");
$tpl = $pdf->importPage(1);
$pdf->AddPage();
$pdf->useTemplate($tpl);
$pdf->SetFont('arial');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(0, 5);
$pdf->Write(0, $bar_code);
$pdf->Cell(20,10,$bar_code,1,1,'C');
$pdf->Output();
?>
also barcode128.php works fine no problem with that. I downloaded it from https://jinujawad.com/create-simple-barcode-using-php/