par
MiaoLee » 26 sept. 2025, 23:40
Bonjourr je rencontre des difficultés avec la dénérations des images sous dom pdf l'image existe bien elle n'est pas endommagé voici mon code:
Code : Tout sélectionner
<?php
// reference the Dompdf namespace
use Dompdf\Dompdf;
use Dompdf\Options;
use Gestionnel\ConnexionDB\Connect;
// somewhere early in your project's loading, require the Composer autoloader
// see: http://getcomposer.org/doc/00-intro.md
require_once '../vendor/autoload.php';
require_once '../cl/Connect.php';
$idfoyer = intval($_POST['id_foyer']);
$rs_foyer = Connect::conne()->prepare('SELECT DISTINCT
f.id_foyer,
f.designation,
f.actif,
f.adresse,
f.code_postal,
f.idx_ville,
vf.ville_nom,
f.mail,
f.portable,
f.fixe,
f.logo,
f.siret,
f.description
FROM foyer f
INNER JOIN villes_france vf ON vf.ville_id = f.idx_ville
WHERE id_foyer = ?');
$rs_foyer->execute([$idfoyer]);
$foyer = $rs_foyer->fetch();
//logo Gestionnel
$logoGestionnel = 'img/logo/gesrtionnel-black.png';
// On recherche le qrcode
// $qrcode = basename(SITE_MASTER.DIRECTORY_SEPARATOR.'qrcode/2.png');
// $qrcode = basename('https://gestionnel.fr/application/public/qrcode/2.png');
// $qrcode = 'https://gestionnel.fr/application/public/qrcode/'.$idfoyer.'.png';
$qrcode = 'application/public/qrcode/'.$idfoyer.'.png';
// On recherche le logo de l'association
$logo = 'logo-foyer/'.$foyer['logo'];
ob_start();?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QRcode</title>
<link rel="stylesheet" href="pdf.css">
</head>
<body>
<div class="center">
<p class="text-center"><img class="align-top text-center" src="<?= $logoGestionnel ?>" alt="Gestionnel" height="120"></p>
</div>
<h2 class="text-center">Pré-inscription</h2>
<p class="text-center"><img src="<?= $logo ?>" alt="" height="150"></p>
<p class="text-center"><img src="<?= basename('https://gestionnel.fr/application/public/qrcode/2.png')?>" alt="" height="300"></p>
</body>
</html>
<?php
$html = ob_get_contents();
ob_end_clean();
$options = new Options();
$options->set('defaultFont','Arial');
$options->set('isRemoteEnabled',true);
// instantiate and use the dompdf class
$dompdf = new Dompdf($options);
$dompdf->getOptions()->setChroot(__DIR__);
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
$fichier = 'Fiche adhérent ';
// Output the generated PDF to Browser
$dompdf->stream($fichier);
Merci d'avance pour vos éclaircissements.
Bonjourr je rencontre des difficultés avec la dénérations des images sous dom pdf l'image existe bien elle n'est pas endommagé voici mon code:
[code]<?php
// reference the Dompdf namespace
use Dompdf\Dompdf;
use Dompdf\Options;
use Gestionnel\ConnexionDB\Connect;
// somewhere early in your project's loading, require the Composer autoloader
// see: http://getcomposer.org/doc/00-intro.md
require_once '../vendor/autoload.php';
require_once '../cl/Connect.php';
$idfoyer = intval($_POST['id_foyer']);
$rs_foyer = Connect::conne()->prepare('SELECT DISTINCT
f.id_foyer,
f.designation,
f.actif,
f.adresse,
f.code_postal,
f.idx_ville,
vf.ville_nom,
f.mail,
f.portable,
f.fixe,
f.logo,
f.siret,
f.description
FROM foyer f
INNER JOIN villes_france vf ON vf.ville_id = f.idx_ville
WHERE id_foyer = ?');
$rs_foyer->execute([$idfoyer]);
$foyer = $rs_foyer->fetch();
//logo Gestionnel
$logoGestionnel = 'img/logo/gesrtionnel-black.png';
// On recherche le qrcode
// $qrcode = basename(SITE_MASTER.DIRECTORY_SEPARATOR.'qrcode/2.png');
// $qrcode = basename('https://gestionnel.fr/application/public/qrcode/2.png');
// $qrcode = 'https://gestionnel.fr/application/public/qrcode/'.$idfoyer.'.png';
$qrcode = 'application/public/qrcode/'.$idfoyer.'.png';
// On recherche le logo de l'association
$logo = 'logo-foyer/'.$foyer['logo'];
ob_start();?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QRcode</title>
<link rel="stylesheet" href="pdf.css">
</head>
<body>
<div class="center">
<p class="text-center"><img class="align-top text-center" src="<?= $logoGestionnel ?>" alt="Gestionnel" height="120"></p>
</div>
<h2 class="text-center">Pré-inscription</h2>
<p class="text-center"><img src="<?= $logo ?>" alt="" height="150"></p>
<p class="text-center"><img src="<?= basename('https://gestionnel.fr/application/public/qrcode/2.png')?>" alt="" height="300"></p>
</body>
</html>
<?php
$html = ob_get_contents();
ob_end_clean();
$options = new Options();
$options->set('defaultFont','Arial');
$options->set('isRemoteEnabled',true);
// instantiate and use the dompdf class
$dompdf = new Dompdf($options);
$dompdf->getOptions()->setChroot(__DIR__);
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
$fichier = 'Fiche adhérent ';
// Output the generated PDF to Browser
$dompdf->stream($fichier);
[/code]
Merci d'avance pour vos éclaircissements.