htmlpdfweasyprint

How can I force weasyprint to use the colors in PDF?


When I use

$ weasyprint table.html table.pdf

on https://jsfiddle.net/MartinThoma/0hL29mcc/ it generates a PDF which looks like this:

enter image description here

As you can see, the heading is black, not red. Also, the table is not striped anymore.

Somehow weasyprint removes all colors. How can I prevent this behaviour / keep the colors? (I don't necessarily need to use weasyprint, but I don't know any better alternative)

I use WeasyPrint version 0.40.

What I've tried


Solution

  • The main problem is that Bootstrap 3 contains the following:

    @media print{
        *,:after,:before {
            color:#000!important;
            text-shadow:none!important;
            background:0 0!important;
            -webkit-box-shadow:none!important;
            box-shadow:none!important
        }
    }
    

    So weasyprint is actually behaving as intended. Removing this leads to the expected results.