background-color property is not working
I had similar case with yours. My solution is to add a new selector that pinpoint to the element you want to style. Not its parent, but the element itself.
Forget about inheritance when it comes to background-color and color in html-pdf.
@dorklord23 can you clarify that with an example?
I am not using any inheritance and styling a div directly, yet background-color is completely ignored.
Faced similar issue, fixed it by giving the html element inline style
<div style="background:#007bff;">
The above does not work for me.
Try this in your css file
@media print
{
.body {
background: #00BAFF;
}
}
After trying this again, I discovered that adding !important worked for me, with the class selector solution. Did not need @media print.
@media print nor adding !important are working here. Using bootstrap and trying to use the .table-striped css class.
@jnaklaas did you find solution?
@softmantk no I haven't.
I had similar case with yours. My solution is to add a new selector that pinpoint to the element you want to style. Not its parent, but the element itself. Forget about inheritance when it comes to
background-colorandcolorin html-pdf.
This worked for me.
Adding html { -webkit-print-color-adjust: exact; } in my css worked for me.
@ThibaudREY thanks it worked for me
I didn't know the existence of color-adjust CSS property
I was struggling with another issue where background color and image color weren't the same
@marcbachmann i suggest you mark this issue resolved as the solution provided by @ThibaudREY works perfectly. And update your documentation accordingly. Now I love this package! 👍
@ThibaudREY only this worked for me
I actually managed to resovle this by passing in printBackground: true into the options object. From the docs..
"printBackground - Print background graphics. Defaults to false."
Adding
html { -webkit-print-color-adjust: exact; }in my css worked for me.
Thanks for this, the only solution that really worked for me!!