This is an archived forum post. The information may be outdated. Contact us if you have any questions.

2 style sheets?

kreut wrote on 2012-05-29:
Hello!

First, let me say that I'm really, really impressed with this service. Great job to the programmers!

I do, however, have a question regarding print style sheets. I saw that there was an option to use a print style sheet. The only problem is that I have lots of things that I want to use for both and I don't want 2 sets of style sheets that I have to update (basically, I just need to hide some divs in the pdf). Is there anyway to have 1 style sheet and then specify which of those I want used for the printing?

Thank you,

Eric
support wrote on 2012-05-29:
Hello Eric,

you do not need to maintain 2 style sheets. Just add the following line to your style sheet:
@media print { .no-print {display:none} }

and set the "no-print" class on the elements you want to hide in the PDF. Now if you add the following line (PHP) to your code.
$client->usePrintMedia(True);

the "no-print" elements will not be printed to PDF.

Here is a full example:
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="http://yourdomain/your-standard-stylesheet.css" /> 
    <style>
      @media print { .no-print {display:none} }
    </style>
  </head>

  <body>
    <p>Always visible</p>
    <p class="no-print">Screen only. This will not be printed to PDF.</p>
  </body>
<html>