wkhtmltopdf div background color

Gaurav picture Gaurav · Aug 4, 2014 · Viewed 8.5k times · Source

I am using the wkhtmltopdf on my amazon ubuntu instance to generate an invoice's PDF. The page is PHP. Everything is working fine except the background color of the html div tags. The border color is working fine. Is there any setting in wkhtmltopdf to enable printing background color of the div tag?

I have tried bgcolor, css and inline style, also I have checked converting the page in Table structure but none of these helped.

Answer

Alyssa M picture Alyssa M · Sep 4, 2015

I had this issue as well, and the css was right in the same HTML file. The trick for me ended up being the somewhat-mysterious "!important" at the end of the background-color tag like so:

background-color: #f2f4f7 !important;