Text color not working on window.print() in ui page

snowtech1
Tera Expert

Using window.print() on UI page to have a print popup. The popup does not retain the color of the text on the UI page. Has anyone have this happen?

Any help would be useful.

Thanks in advance.

b-radctomasi

1 ACCEPTED SOLUTION

venkatiyer1
Giga Guru

<style>


@media print {


div {


      color: red !important;


  }


</style>


View solution in original post

8 REPLIES 8

venkatiyer1
Giga Guru

Hi,



Try using @media print css to enable color. So in your UI page add a style tag and the color of the text using @media print. For reference use the link below:-


@media - CSS | MDN


Thank you for the reply.



Tried a couple of things and it didn't work. Already have @media print for excluding href links on the popup. Could you let me know the syntax for color wrt the div below?




<style>


@media print {


  a[href]:after {


      content: none !important;


  }


</style>



<div style="text-align:left; color:red">MESSAGE</div>


venkatiyer1
Giga Guru

<style>


@media print {


div {


      color: red !important;


  }


</style>


Also, even if the print preview does not show up the color the printed material would get the color specified if you were to print from the print window. In a print window, it is still media of screen so it may not show up. If you are particular to show the color on the print screen, you might have to use javascript to make that change.