ppeasy/public/bla.php

57 lines
915 B
PHP

<?php
require 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
use Dompdf\Options;
$options = new Options();
$options->set('isHtml5ParserEnabled', true);
$options->set('isRemoteEnabled', true); // Enable remote files to be fetched
$dompdf = new Dompdf($options);
// HTML content for the PDF
$html = '
<html>
<head>
<style>
body { font-family: Arial, sans-serif; }
.content { text-align: center; }
.content img { width: 100%; max-width: 500px; }
</style>
</head>
<body>
<div class="content">
<h1>Sample PDF with Image</h1>
<img src="http://localhost/cmccopiaoriginale/public/assets/images/ce.jpg" alt="Image">
</div>
</body>
</html>
';
$dompdf->loadHtml($html);
// (Optional) Set up the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream("sample.pdf", array("Attachment" => false));