Salutation, Since a days when i use fpdi for insertion of image in pdf file this response appear : Fatal error: Uncaught Error: Class "setasign\Fpdi\FpdfTpl" not found in C:\wamp\www\QRCode\fpdi\src\Fpdi.php:23 Stack trace: #0 C:\wamp\www\QRCode\CodeQR_2.php(5): include() #1 {main} thrown in C:\wamp\www\QRCode\fpdi\src\Fpdi.php on line 23 i use php version 8.2.0 and fdpi version 2.4.1
i have followed all respones in the forums but not works : i have declared this :
require_once('fpdi/src/Fpdi.php');
require_once('fpdi/src/FpdfTpl.php');
require_once('fpdi/src/autoload.php');
and this:
use setasign\Fpdi\Fpdi;
and just this :
use \setasign\Fpdi;
i have changed in compser :
"require": {
"setasign/fpdi-fpdf": "1.6.1"
}
and this :
$pdf = new \setasign\Fpdi\Fpdi();
and finnaly i have added this:
require_once('fpdi/src/FpdiTrait.php');
the problem exists and the same response appear : Fatal error: Uncaught Error: Class "setasign\Fpdi\FpdfTpl" not found in C:\wamp\www\QRCode\fpdi\src\Fpdi.php:23 Stack trace: #0 C:\wamp\www\QRCode\CodeQR_2.php(5): include() #1 {main} thrown in C:\wamp\www\QRCode\fpdi\src\Fpdi.php on line 23.
this is the modified code:
<?php
include('FPDF/fpdf.php');
include('fpdi/src/Fpdi.php');
include('fpdi/src/FpdfTpl.php');
include('fpdi/src/autoload.php');
use setasign\Fpdi\Fpdi;
$pdf = new setasign\Fpdi\FPDI();
// get the page count
$page = $pdf->setSourceFile('C:/wamp/www/QRCode/fichiers_uploades/UN25042019161632012774.pdf');
// iterate through all pages
// import a page
$templateId = $pdf->importPage($page);
$pdf->AddPage();
// use the imported page and adjust the page size
$pdf->useTemplate($templateId, ['adjustPageSize' => true]);
$image = 'QRCodes/CodeQR1.png';
$pdf->Image($image,110,210);
$file_name2 = 'C:/wamp/www/QRCode/fichiers_generes/UN25042019161632012774.pdf';
// Output the new PDF
$pdf -> Output($file_name2,'F');
?>
i try to add a text in existing pdf file