Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wkhtmltopdf div background color

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.

like image 420
Gaurav Avatar asked Aug 04 '14 12:08

Gaurav


2 Answers

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;
like image 80
Alyssa M Avatar answered Oct 01 '22 16:10

Alyssa M


Use This especially when you generate PDF from google App Script

@media print 
{
.class 
{
     background-color: #1a4567 !important;
     -webkit-print-color-adjust: exact;
}
}
like image 22
Wafik Ramzy Avatar answered Oct 01 '22 18:10

Wafik Ramzy