loading...
Cover image for I made a PDF Version of my Color Pages

I made a PDF Version of my Color Pages

azettl profile image Andreas ・1 min read

I played a little bit with mPDF and now all the color pages on my website offer amazing looking PDFs to download.

Next to the social share buttons for Facebook and Twitter you can find the new PDF export.

Most of the time I spend working around CSS limitations of mPDF like that they do not support pseudo elements.

The rest is pretty easy, just create a new mPDF instance, add a page, write the HTML and print the result.

$mpdf = new \Mpdf\Mpdf([
    'format' => 'A5',
]);

/* Add a additional stylesheet */
$mpdf->WriteHTML($inline_stylesheet,\Mpdf\HTMLParserMode::HEADER_CSS);
$mpdf->AddPage('P');
$mpdf->WriteHTML('<h1>Hello dev.to</h1>');
$mpdf->Output();

Some Screenshots


Sample Links

https://convertingcolors.com/hex-color-ED2B55.pdf
https://convertingcolors.com/rgb-color-214_194_115.pdf

Discussion

markdown guide