MPDF how to use alpha transparent?

im using MPDF to create a pdf file with full page background. I want to make a layout on it like this image. enter image description here

I think need to use alpha transparent, but i dont know how

This is my code

$pdfOptions = array(
    'mode'              => 'utf-8',
    'format'                => 'A4-L',
    'img_dpi'               => 300,
    'dpi'                   => 300,
require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new MpdfMpdf($pdfOptions);


#cover {
  background-color: #dddddd;


<div id="cover" style="position: absolute; left:0; right: 0; top: 0; bottom: 0; width: 297mm; height: 50mm;">

$mpdf->WriteHTML("<html><body style='background-image:url("images/1.jpg"); background-image-resize: 5; background-position: top center;'></body></html>");

$mpdf->WriteHTML('<p>Text for item 1</p>');



enter image description here

Im trying to use opacity

#cover {
width: 297mm;
 height: 50mm;
  background-image: url("images/b.png");
  background-image-resize: 5;
  background-position: center center;
  background-image-opacity: 0.5;


but the result like this enter image description here


rgba is supported by mPDF, so the style should be something like this, where last is alpha value:

#cover {
  background-color: rgba(221, 221, 221, 0.5);

Leave a Reply

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