Why doesn't Google Chrome print the borders of tables and cells, as well as the background color of the cell?

I support a web application built using GWT that has historically been developed to work only on Google Chrome.

There are several “reports” that can be retrieved from the system. The way this is implemented is as follows: firstly, the html for the report is created and displayed in the section of the screen (this works correctly). After that there is a button that allows you to print a report. This action generates html with the information (in the html table) in the same way as for creating a report on the screen, and uses it to create an html file, which is then sent for printing. A.

Here the monster shows its face! (tum-dum-dummmm - dramatic music).

Since Google Chrome has been updated to version 59.0.3071.86, when printing tables / cells lose borders and background colors.

I thought that maybe this was due to the html created, but actually, if I force html to print

<!DOCTYPE html>
<html>
   <head>
      <style>table, th, td {border: 1px solid black !important;}</style>
      <title>title</title>
   </head>
   <body>
      <h2>Add a border to a table:</h2>
      <table>
         <tr>
            <th>Firstname</th>
            <th>Lastname</th>
         </tr>
         <tr>
            <td>Peter</td>
            <td>Griffin</td>
         </tr>
         <tr>
            <td>Lois</td>
            <td>Griffin</td>
         </tr>
      </table>
   </body>
</html>

the table still doesn't print correctly (and this is also seen in the Chrome print preview (yes, even with the ability to select background images)). The same thing happens if I draw a table on the table tag itself. Sort of:

<table style="border: 1px solid black !important;">

I have no ideas, so I ask if anyone has a similar problem or have any idea what I can try.

Thanks in advance.

, , , " ". " " , . (, ) , , , , . 59.0.3071.86, , , , " - 5 ".

, :

- webapp, , "print report". html , . html , . , " ", "" html:

<!DOCTYPE html>
<html>
   <head>
      <style>table, th, td {border: 1px solid black !important;} body { -webkit-print-color-adjust: exact; } </style>
      <title>title</title>
   </head>
   <body>
      <h2>Add a border to a table:</h2>
      <table>
         <tr>
            <th>Firstname</th>
            <th>Lastname</th>
         </tr>
         <tr>
            <td bgcolor="#FF0000">Peter</td>
            <td>Griffin</td>
         </tr>
         <tr>
            <td>Lois</td>
            <td>Griffin</td>
         </tr>
      </table>
   </body>
</html>

,

body { -webkit-print-color-adjust: exact; }

, , , :

<table style="border: 1px solid black !important;">

<body style="-webkit-print-color-adjust: exact;">

"html testbed", , html:

Table with borders and TD background.

, "", , :

I'm looking at the error

, ( , SO, , ), .

: " CSS ", :

<!DOCTYPE html>
<html>
   <head>
      <style>
         @media print { 
             body { -webkit-print-color-adjust: exact; } 
             table, th, td {border: 1px solid black !important;} 
         }  
      </style>
      <title>title</title>
   </head>
   <body>
      <h2>Add a border to a table:</h2>
      <table>
         <tr>
            <th>Firstname</th>
            <th>Lastname</th>
         </tr>
        <tr>
           <td bgcolor=\"#FF0000\">Peter</td>
           <td>Griffin</td>
        </tr>
        <tr>
           <td>Lois</td>
           <td>Griffin</td>
        </tr>
    </table>
   </body>
</html>

, . (, , ... , , ), , , , , // ( ).

- : , , . , , , , , -:

, , : , , html, ( , ), javascript, . , , .

, , - " ". : "!". ( , ).

+6
1

?

<table border="1px" bgcolor="green">
<tr>
<td>ANYTHING RANDOM
</td>
</tr>
</table>

.

0

All Articles