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 69
| <?php
$Nom_Fichier = "_page_test.pdf";
$html = "<table border='1' width='100%' style='border-collapse: collapse;'>
<tr>
<th>Username</th><th>Email</th>
</tr>
<tr>
<td>yssyogesh</td>
<td>yogesh@makitweb.com</td>
</tr>
<tr>
<td>sonarika</td>
<td>sonarika@makitweb.com</td>
</tr>
<tr>
<td>vishal</td>
<td>vishal@makitweb.com</td>
</tr>
</table>";
// include autoloader
require_once 'dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// Instantiate and use the dompdf class
$dompdf = new Dompdf();
try {
$dompdf = new Dompdf();
}
catch(Exception $e) {
echo "<br>Message : " . $e->getMessage();
echo "<br>Code : " . $e->getCode();
echo "<br>$dompdf = new Dompdf();";
die();
}
// Load HTML content
$dompdf->loadHtml('<h1>Welcome to CodexWorld.com</h1>');
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'landscape');
$dompdf->loadHtml($html, true);
// Render the HTML as PDF
try {
$dompdf->render();
}
catch(Exception $e) {
echo "<br>Message : " . $e->getMessage();
echo "<br>Code : " . $e->getCode();
echo "<br>$dompdf = new Dompdf();";
die();
}
// Output the generated PDF to Browser
//$dompdf->stream("codexworld", array("Attachment" => 0));
try {
$dompdf->stream($Nom_Fichier, array("Attachment" => 0));
}
catch(Exception $e) {
echo "<br>Message : " . $e->getMessage();
echo "<br>Code : " . $e->getCode();
echo "<br>$dompdf = new Dompdf();";
die();
}
echo $html;
?> |
Partager