Weasyprint and CSS

Viewed 572

I seem to be struggling with weasyprint and CSS,

The main issues that I seem to not be able to get working is background colors on things.

the HTML uses bootstrap to render and I seem to get the grid layouts and the table formatting but the background colours seem to go missing.

I have tried inline css and that does not come out either.

I know this one is a little obscure but I am not sure what to show you guys.

I am happy for feedback on the question so I can refine what I am asking.

Thanks Guys in advance

Here is the weasyprint object:

weasyprint.HTML(
            string=self.html_accept(request, report, clinic_id), media_type='print'
        ).write_pdf(stylesheets=[weasyprint.CSS(url='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css')])

I have also tried adding the stylesheet as a string to get the background and that does not seem to work.

Here is the HTML that I am having issues with.

        <tr class="table-primary text-white">
            <td></td>
            <td>&nbsp;&lt;5 years</td>
            <td>&nbsp;&ge;5yrs (excluding PW)</td>
            <td>&nbsp;Preg Women (PW)</td>
            <td>Total&nbsp;</td>

        </tr>

and I have overridden the bootstrap colour like this.

        <style>
            .table-primary, .table-primary>td, .table-primary>th .table-primary>tr{
                background-color: #459EAD;
            }
        </style>

this works when rendering the html but not when printed to pdf

0 Answers
Related