When generating a PDF using mPDF (containing images), no images will show. The text displays just fine. For some reason it does add several blank pages to the PDF. Even though it has a footer text set for every page, these are still blank.
Tried to enable $mPdf->showImageErrors, this does not give any errors, also tried to search the error log. There are no errors thrown. Tried to catch any MpdfException. But none are thrown.
{twig tempalte}
<html>
<head>
<style>
body {
font-family: "Times New Roman", Times, serif;
font-size: 10px;
line-height: 14px;
}
thead {
font-weight: bold;
}
table {
margin: 15px 0;
padding: 0;
}
td {
width: 165px;
}
tr {
margin: 10px 0;
}
td table {
border-spacing: 0;
}
th {
text-align: left;
}
.container {
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
.row {
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
}
.full-table td {
width: 100%;
}
</style>
</head>
<body>
<div class="row">
<table class="full-table">
<tr>
<th>Screenshot</th>
</tr>
<tr>
<td><img src="{{ asset('/images/path/to-image.png') }}"/></td>
</tr>
</table>
</div>
<div class="row">
<table class="full-table">
<tr>
<th>Screenshot</th>
</tr>
<tr>
<td><img src="{{ asset('/images/path/to-second-image.png') }}"/></td>
</tr>
</table>
</div>
</body>
</html>
$mPdf = new Mpdf();
$template = {twig template}
$filePath = '{var/location}';
$mPdf->watermarkImageAlpha = 1;
$mPdf->watermark_size = 'D';
$mPdf->watermark_pos = [107, 0];
$mPdf->showWatermarkImage = true;
$mPdf->watermarkImgBehind = true;
$mPdf->WriteHTML($template);
$mPdf->Output($filePath, Destination::FILE);
Expected for it to display images and background image, none are showing.
assettwig function produces the paths for web, however, Mpdf doesn't know or care about paths for the web and only cares about paths that mean something in the filesystem. Just because Mpdf uses HTML as it's language to describe pdf contents, doesn't mean it employs a web browser to actually load those... meaning, you probably have to find/write a function different fromassetto get the correct path to your images.assetdoes not work. When I changed it to full path it worked. Thanks for the help!