1560
Views
5
Comments
[Simple Reports With PDF] Background Color not displayed in final PDF
Question
simple-reports-with-pdf
Web icon
Forge asset by Huarlem Lima

Hello!

I'm using this component and I realized that the background colors of the DIVs are not being displayed in the final PDF.

Have you experienced this behavior before? Do you know how to overcome it?

Thanks

2023-12-07 07-51-40
Remco Dekkinga
 
MVP

Hi Hernâni,

The PDF functionality is coming from the HTML2PDF component which in this case is based on the wkhtml2pdf executable.

There is indeed a bug in this utility, which is mentioned also here: https://stackoverflow.com/questions/25118343/wkhtmltopdf-div-background-color

By adding a !important behind the CSS lines that give the color in your app, you should be able to overcome this issue.

Let us know if this work-around solves your issue.

Kind regards,

Remco Dekkinga

2018-12-10 09-33-47
Hernâni Fernandes
Staff

Hello, Remco.

Thanks for your reply. 

I wasn't able to solve the issue. Do you think you can show me an example in a oml?

Thanks

 Dekkinga wrote

Hi Hernâni,

The PDF functionality is coming from the HTML2PDF component which in this case is based on the wkhtml2pdf executable.

There is indeed a bug in this utility, which is mentioned also here: https://stackoverflow.com/questions/25118343/wkhtmltopdf-div-background-color

By adding a !important behind the CSS lines that give the color in your app, you should be able to overcome this issue.

Let us know if this work-around solves your issue.

Kind regards,

Remco Dekkinga



2018-08-26 20-34-32
Pankaj pant

Hi Hernâni,


Try to use media print query may be it will solve your problem

Like below.

@media print 
{
.class 
{
     background-color: #1a4567 !important;
     -webkit-print-color-adjust: exact;
}
}

But make sure you have to write This piece of code to get background color.


 -webkit-print-color-adjust: exact;


Regards,

Pankaj 

2016-08-12 19-14-19
Bruce Buttles

Hernâni Fernandes, did the last fix from Pankaj work?

2014-12-24 13-44-21
Keith Matthews

I have a variation of this issue in that the pdf screen comes up the colors, when I print the pdf screen to a pdf file it keeps the colors, but when I download the pdf screen to a pdf it loses the colors from the table records header background and the odd and even lines background.

Has anyone made this work completely?


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.