Does wkhtmltopdf respect css font color?

2019-07-18 11:34发布

I'm using wkhtmltopdf to generate a pdf of a page but it doesn't display any of the fonts in the correct colour, they all are presented black.

The colour is defined as you'd expect:

.panel-dashboard p.stat {
  color: #bed000;
}

and displays correctly when viewed in the browser.

I'm calling it as

wkhtmltopdf path/to/page filename

Does wkhtmltopdf just not render font colours correctly? I've not been able to find any issues relating to this.

2条回答
祖国的老花朵
2楼-- · 2019-07-18 12:10

Using version 0.12.2.4 specifying a white font inside the CSS (inside a grey background) worked, but a colored font (red, orange) did not:

.header { background-color: #888; color: #fff; } /* works */
.orange { color: f80; } /* doesn't work in wkhtmltopdf */

Using a style directly on the div did work:

<div style="color:#f60;">My Orange Text</div>

It may be because there is no background?? I don't know.

So if you try CSS and it fails this may work...

查看更多
SAY GOODBYE
3楼-- · 2019-07-18 12:19

Appears this was a problem with wkhtmltopdf 0.9.9, 0.11 renders css font colors correctly.

查看更多
登录 后发表回答