1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| <?php
/************************************************************
* Definition des constantes / tableaux et variables
*************************************************************/
// Constantes
define('TARGET', 'images/trombinoscope/'); // Repertoire cible
echo "Page de test";
$html = "<!DOCTYPE html>
<html lang='fr'>
<head>
<style type='text/css'>
.header,
body {
font-size: 65%;
}
.footer {
width: 100%;
text-align: center;
position: fixed;
}
.header {
top: 25px;
}
.footer {
bottom: 0px;
}
.pagenum:before {
content: counter(page);
}
</style>
</head>
<body>
<center>
ceci est un test
</center>
</body>
</html>";
require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
/// Instantiate and use the dompdf class
try {
//$Nom_Serveur = Recup_Adresse_Serveur();
$Nom_Fichier = TARGET . "Page_Test.pdf";
$dompdf = new Dompdf();
// Load HTML content
$dompdf->loadHtml($html, true);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream($Nom_Fichier, array("Attachment" => 0));
} catch(Exception $e) {
echo "<br>Erreur à la ligne " . $e->getLine() . " dans le fichier " . $e->getFile() . ". <br>Une exception a été lancée : " . $e->getMessage();
die();
}
?> |