user1016403
user1016403

Reputation: 12621

How to apply CSS style while printing?

I am using GWT/GXT.

i have used GWT's grid and each row is highighted in background color using CSS. but applied css is not printed in printed page. how can i print with css?

I am calling Print functionality as below:

Print.it("<link rel='StyleSheet' type='text/css' media='paper' href='mainApplication.css'>", DOM.getElementById("myId"));

in mainApplication.css i placed style as below:

@media print {
    print_background {
    background-color: #EBECE4 !important;
    }
  }

is my CSS style correct? Please help me.

in the code :

i created a horizontal panel and added GWT grid to it as below.

HorizontalPanel recordsPanel = new HorizontalPanel();

//GWT grid is created and the same is added to recordsPanel 
recordsPanel .add(grid).

i applied css style for grid rows as below:

recordsGrid.getRowFormatter().addStyleName(i, "print_results_background");

Now i want to print the records with css style.

Thanks!

Upvotes: 0

Views: 1499

Answers (3)

Eliran Malka
Eliran Malka

Reputation: 16263

paper is not a valid value for the media attribute. Correct your link tag as follows:

<link rel='stylesheet' type='text/css' media='print' href='mainApplication.css' />

Ignoring other syntactic mistakes as mentioned by other posters, please refer to RAS's comment on the question also (regarding the differing class name).

Reference

Upvotes: 1

Santiago Rebella
Santiago Rebella

Reputation: 2449

I think you are missing in the css to specify if print_background its an id # or a class .

Upvotes: 0

g.annunziata
g.annunziata

Reputation: 3276

You CSS style isn't correct for a trivial issue: lack of dot (.) before print_background class. Correct code is:

@media print {
     .print_background {
           background-color: #EBECE4 !important;
     }
}

Upvotes: 1

Related Questions