Forum How do I...?

Hiding content from print

somebee
Hi. Is it possible to hide certain elements when printing? I want to show something in the pdf itself on the screen, but hide it in the printed version.
If possible, how can I achieve it?

Thanks
mikeday
You could use a print-specific rule in your style sheet:
@media print {
    .foo { display: none }
}

where "foo" is an element class you wish to hide.
somebee
Haha, I cannot even begin to describe how awesome princexml is..
its almost ridiculous :-)

Thanks mike!
zweem
My question is probably even more trivial, but what do I add or change in the css file if I want to hide elements permanent (when viewing or printing)?

A trial & error session wasn't successful.

Thanks in advance!
mikeday
Simply setting "display: none" for these elements should do the trick.
zweem
Got it working! I'm not even gonna tell what I did wrong :oops:
somebee
Hmm, Mike, is it possible to show something in the pdf, but hide it from the actual printing of the pdf? With the tip above it is hidden in the pdf when shown in a pdf-viewer as well. I realize this might not be possible, but thought I'd hear!
mikeday
The "P" logo that Prince adds for the non-commercial license is displayed in the PDF viewer but not printed. However Prince does not have any way for doing this to arbitrary content in the document at this time.