Hello Readers ,
Below is the explanation of how we can create any HTML into PDF and then further send it to emails as an attachment etc.
Install the Dompdf library from github https://github.com/dompdf/dompdf/releases and then put it into your project.
With Dompdf downloaded, let’s write a short example that will generate a simple PDF.
<?php
set_include_path(get_include_path() . PATH_SEPARATOR . "/path/to/dompdf");
require_once "dompdf_config.inc.php";
$dompdf = new DOMPDF();
$html = <<<'ENDHTML'
<html>
<body>
<h1>Hello Dompdf</h1>
</body>
</html>
ENDHTML;
$dompdf->load_html($html);
$dompdf->render();
$output = $dompdf->output();
file_put_contents("/path/to/file.pdf", $output);
?>
That's it.
0 Comment(s)