Bootstrap: Tables are not printing correctly

Created on 27 Jan 2018  路  6Comments  路  Source: twbs/bootstrap

Hello,
today I've added feature to print tables from my website.
Then I have noticed that tables with classes below are not printing correctly, although they are displayed correctly on screen.

  • <thead class="thead-dark"> - Header and font are both white so header is not readable

  • <table class="table table-dark"> - Like header, whole table is white, including the font.

  • <table class="table table-striped"> - There are no striped rows when printing. Class has no effect when printing. Print result is the same with and without it.

At first I suspected that something is wrong with my website (that my CSS is overriding Bootstrap CSS because it is linked after it), but then I tried to print tables from official Bootstrap website and got the same issue.

I'm using Bootstrap v4.0

Hope this will be resolved soon.
Thanks.

css v4

Most helpful comment

@mdo "Unsure how much we should override that, which would screw things up for folks who want that background-color"

Well, Bootstrap definitely overrides it and sets the background to white. Shouldn't it be inherit so that you don't override any colors that we've set in the table cell? Seems like Bootstrap is telling developers how things should print, instead of developers telling Bootstrap how it should print things.

All 6 comments

Background colors aren't always printed; there's usually a browser option for that. Unsure how much we should override that, which would screw things up for folks who want that background-color.

@ewaschen @duksi1993
Try to use -webkit-print-color-adjust: exact; like this:

.elementWhichShouldBeRedAndBlue {
    background-color: red;
    color: blue;
    -webkit-print-color-adjust: exact;
}

Did this ever get fixed? I'm using v4.1.3 and rendering PDFs with puppeteer, but the coloring is still off. I've tried setting -webkit-print-color-adjust: exact; on the appropriate elements as well.

Did this ever get fixed? I'm using v4.1.3 and rendering PDFs with puppeteer, but the coloring is still off. I've tried setting -webkit-print-color-adjust: exact; on the appropriate elements as well.

Same, I still don't see any of my color printed.

@mdo "Unsure how much we should override that, which would screw things up for folks who want that background-color"

Well, Bootstrap definitely overrides it and sets the background to white. Shouldn't it be inherit so that you don't override any colors that we've set in the table cell? Seems like Bootstrap is telling developers how things should print, instead of developers telling Bootstrap how it should print things.

It's a real problem, need to be fixed!

Was this page helpful?
0 / 5 - 0 ratings