Using MPDF in PHP code

I have recently found the need to generate a PDF from the content of a dynamic HTML page.

I found a really useful product that allowed me to change the PDF layout via CSS, which allowed me to have a coloured back ground on my page, but have a white background on my  PDF.

I used a product called MPDF

$htmlfile = "myfile.html";

$pdffile = "myfile.pdf";

//PDF Generation
$htmlGen = file_get_contents($htmlfile);
$mpdf = new mPDF();
$stylesheet = file_get_contents('css/PageStyleResults.css');
$mpdf->Output($pdffile, 'F');

Using the F switch in the output allowed me save a copy of the PDF, which I then send out by email.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.