Class "setasign\Fpdi\FpdfTpl" not found when using fpdi and
Résoluzakri-04 Messages postés 21 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je suis en train d'utiliser fpdi pour insérer le code QR dans un fichier PDF mais ce massage me suit depuis des jours :
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
j'utilise php version 8.2.0 and fdpi version 2.4.1
j'ai suivi presque toutes les réponses dans les différents forums mais rien à chnager:
j'ai déclaré
require_once('fpdi/src/Fpdi.php'); require_once('fpdi/src/FpdfTpl.php'); require_once('fpdi/src/autoload.php');
et ça :
use setasign\Fpdi\Fpdi;
use \setasign\Fpdi;
j'ai changé dans le compser :
"require": { "setasign/fpdi-fpdf": "1.6.1" }
j'ai changé la déclaration :
$pdf = new \setasign\Fpdi\Fpdi();
require_once('fpdi/src/FpdiTrait.php');
toujours le problème.
voici un des codes :
<?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'); ?>
- Fpdi.php
- Spybot search and destroy - Télécharger - Antivirus & Antimalwares
- Vb6fr.dll could not be found - Forum Windows
- The realtek network controller was not found ✓ - Forum Pilotes (drivers)
- Find and mount - Télécharger - Récupération de données
- Alert hard drive not found ✓ - Forum Windows
3 réponses
J'ai trouvé la solution en cherchant sur youtube : 1)installer depuis le composer : composer require setasign/fpdi-fpdf 2)Le code : <?php use setasign\Fpdi\Fpdi; require_once('vendor/autoload.php'); $file = 'fichiers_uploades/UN250420191895923066.pdf'; $image = 'QRCodes/CodeQR1.png'; $pdf = new Fpdi(); if(file_exists("./".$file)){ $pagecount = $pdf->setSourceFile($file); }else{ die('Source PDF not found!'); } // Add watermark image to PDF pages for($i=1;$i<=$pagecount;$i++){ $tpl = $pdf->importPage($i); $size = $pdf->getTemplateSize($tpl); $pdf->addPage(); $pdf->useTemplate($tpl, 1, 1, $size['width'], $size['height'], TRUE); //Put the watermark $xxx_final = ($size['width']-60); $yyy_final = ($size['height']-65); $pdf->Image($image, $xxx_final, $yyy_final, 0, 0, 'png'); } // Output PDF with watermark $pdf->Output('F', 'fichiers_generes/UN250420191895923066.pdf');