Ben
Ben

Reputation: 927

Drupal pop-up window for printing

I have a Drupal website and I need to create a link to a different version of the same page that opens up in a new window but hides all the side bars, blocks and header and just shows the main content. This is so people can print the main content of the page without all the extra bits.

I know I can add in a link to a print version like <a href="print version of page" target="_blank">print version</a>. But then I want to add a new CSS class to the page which I could use to hide the extra bits. I am not sure how I can add the CSS class to the link/page.

I guess I could also use Javascript but not sure about which method to use for this.

Upvotes: 1

Views: 1460

Answers (3)

Jason Gennaro
Jason Gennaro

Reputation: 34855

You do not need to create a new print-only page.

Instead, you can just add something like the following to the bottom of your stylesheet and the user will print the page without the extras.

@media print {

body {background-image:none; background-color:#fff;} //turns off bg images
                                                     //sets bg to white 

div#header, div#footer, div#nav {display:none;} //hides elements
                                                //change to match your divs etc.

h1, h2, h3, h4, h5, ul, ol, div, p, a {color:black;} //changes text to black

}

Upvotes: 0

baraboom
baraboom

Reputation: 1408

If the Drupal Print module doesn't work for you (for some reason), the standard method for creating a print view utilizing CSS is to include in your primary stylesheet the following:

@media print {
  /* style sheet for print goes here */
}

You would redefine the classes, elements, etc inside that stanza to change or suppress them for printing.

Good luck!

Upvotes: 2

Try the Drupal Print module, it provides customization for printing pages in Drupal.

Upvotes: 4

Related Questions