I spent way too much time on this and I can't figure out a good 21th century solution.
Simply I have to generate a business card in PDF with a background image, but MPDF isn't very helpful.
By default I had:
@page{
sheet-size: 90mm 55mm;
margin: 0;
}
I tried to:
doesn't work
doesn't work
div
with background imageimg
tags, using src
attribute.At the last option, I've got a really strange thing. It showed the whole image but in a small rectangle in the pages, but not even in full height.
Does anyone have an idea, how to simply use an image as a page background?
mPDF has a custom css property for background images: background-image-resize with custom values from 0-6:
So you probably need: body {background-image:url(something.png); background-image-resize:6}
Taken from mPDF docs
Working example with the background-image-resolution
property :
<body style="background-image: url('/absolute/path/to/image.jpg');
background-position: top left;
background-repeat: no-repeat;
background-image-resize: 4;
background-image-resolution: from-image;">
It works fine with a 300DPI JPEG picture on invoices.
if you use both the
style="..."
tag and abody{...}
style in CSS, mpdf will ignore thestyle="..."
tag and its content, so the picture will not appear!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With