I have amended foliage to include a printing stylesheet. This will ensure only the article (page/story/...) being viewed is printed and none of the sidebars, header or footer graphics are printed. This print styling is available with Garland, Zen and many other themes.
Attached is the print.css stylesheet. This should be saved to the foliage theme directory as print.css (note you MUST drop the .txt extension).
You must also edit the page.tpl.php file which is in the foliage theme directory. The line which begins "less than sign"style... is the line you need to add. It needs to be added where shown.
<?php print $styles ?>
<style type="text/css" media="print">@import "<?php print base_path() . path_to_theme() ?>/print.css";</style>
<?php print $scripts ?>
Background on this approach is to be found in the following post: http://drupal.org/node/102840
The print.css was sourced then amended from: http://www.alistapart.com/articles/goingtoprint/
Perhaps Bjarne would like to add this to the next release of foliage.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | ie7-print-admin-page-with-graphics.pdf | 163.59 KB | netbjarne |
| #2 | print.css__0.txt | 898 bytes | vjordan |
| #1 | firefox-print.pdf | 61.42 KB | netbjarne |
| print.css_.txt | 633 bytes | vjordan |
Comments
Comment #1
netbjarne commentedSplendid idea!
The print.css allows page content to be printet without the blocks containing navigation. However, there is room for improvement (althoug I don't know if it is do'able using only a css).. Because, tabs, are still being printed. So is search field and comment links. Please see attached pdf's.
Comment #2
vjordan commentedThanks for the feedback. Here's an attempt to reduce the room for improvement!
The tabs no longer print. And the search box may no longer print. (My adaptation of foliage doesn't include the searchbar so I can't easily verify this.)
Comments
In my case I want to see all the comments associated with the node, and I can live with the comment action links being printed because there is only page on my whole site which has comments enabled.
To illustrate how print.css can be adapted to turn off the comment actions I have made the "comment_add" style into non printing. I have also documented the css to explain which other styles may need to be changed to make all comment actions non printing. Do you think these should all be made non printing by default?
Please let me know if there are other areas which look unusual or need attention.
Comment #3
netbjarne commentedWow. It looks like its possible to actually make printed webpages look, well, great!
I applied your modified css. Gone are printed tabs, and printed search field and search button. Good work!
Just to see how it would look, I deleted the "times roman 12 point" font override from print.css. What looks best is up to discussion, serif fonts (like times) are known to be more easily readable on print - but I wanted to see how close we could get to the original foliage theme....
Therefore, I also instructed IE to print the background colors. The results are looking very promising. Take a loot at the attachment. I have got two comments:
a) position of site name in the header is off - that might require edit of the page.tpl file??
b) the submit buttons (save changes, reset) are no good on print ;-)
Another thing: Firefox seems to print url's of links in readable form - is that an option somewhere?
Bjarne
Comment #4
vjordan commentedYes, the print of your admin page looks good with the background images.
Yes, I took Times New Roman as the printable font from the recommendations in the alistapart article I refer to in #1 above. It is a question of style and purpose: to make it easy to read on paper or to look like the web display.
Yes, I agree the submit buttons aren't a whole lot of use on the printed page. But I don't want to make something useful disappear either! Maybe I should turn them off for now.
Yes, printing the URLs out is configured in the last section of the css file. So it doesn't work on IE7? Hmmm I didn't realise that. I'll probably turn that feature off too as most links on this site are internal and will possibly confuse visitors.
I would expect the positioning of sitename could be controlled by an override in the print.css. You'd need to identify what is causing the difficulty: possibly in the margin setting of site name or maybe the site slogan? Or maybe the font size? All can be fixed with a print.css override.
Comment #5
netbjarne commentedI did some hacking on your print.css - below is what i learned, and a sample I'd like you to try out:
a) the false position of the sitename in the header was a result of the print.css hiding the entire table cell with the search form. hiding #search-theme-form instead, hides the seach form, but not the cell, and this positioning is again correct
b) buttons are .form-submit styled - I've hid them as well (could be optional, documented in readme)
c) RSS feed icon is .feed-icon styled - also hidden.
d) body text is again 12point serif font - I have left headers to their original styling, except:
e) text colors are all black - this speeds up printing a lot (at least on our multipass color printer)
f) header and footer looks ok without background image, but shines with background image enabled - I have tried this in IE7 and Firefox 2 in portrait and landscape mode (slows down printing of cause)
g) i have removed extra margins on content, browser adds margins on print as well..
Gotta go! - tell me what you think?
Comment #6
netbjarne commentedJust forgot: live working sample of hack: http://test.oldrup.dk/node/1
Comment #7
vjordan commentedLots of good improvements in your latest version.
I like most of the changes. I have further modified as follows:
Any further changes required? More documentation needed (to display or not display the header / footer images)? Ready to be committed?
Comment #8
netbjarne commentedI like the changes.. I guess we could release it as it is...
However, I have experienced inconsistencies in how IE, Firefox and Opera renders the output. While thats not a big issue, it annoys me a lot. The page title seems gray instead of black in IE, and some browsers renders horizontal borders while others don't... That does not male print.css unusable, its a big improvement over no print.css, but it really annoys me - especially the part that after fiddling with the css for several hours, I didn't get the slightest bit closer to a solution. Like it or not, IE is still the most frequently used browser, and I think we should support it as best as we can.
So... Is this getting to a conclusion or?
I guess so. I say, unless vjordan have any idea to fix the inconsistencies we go ahead and release the print.css. Yes - it can still be improved, but its absolutely useful as it is..
Comment #9
vjordan commentedI don't have any real ideas on fixing the inconsistencies. I might get an opportunity to fix them between other tasks I have on, although I'm not a css expert.
I would suggest releasing it as-is. Perhaps include a comment in the print.css header which says "If you experience any inconsistencies on IE, opera, konquerer (?) please post an issue against foliage on drupal.org" That way the problems will be noted, and the user might even have suggestions to solve them.
Comment #10
netbjarne commentedI agree. The print.css addition to Foliage is good as it is, and there is no reason to be picky about minor inconsistencies between IE and Firefoxs rendering of the printer friendly pages, as long as print.css is a major improvement when it comes to printing in both browsers.
However, I'm leaving the Foliage development for the time being, and I'm not tempted by the hassle of installing/configuring/trying-to-understanding a CVS client at the moment, so I will not be able to provide a prober release (whats wrong with good ol' ftp ;-))
So – to take advantage of print.css, you'll have to add a few lines to page.tpl.php as described in this issues first post, and create the print.css file – i suggest you copy the code of comment #7. Its less than 5 minutes work and worth it.
To vjordan: Great work – and thank you for contributing to the Foliage theme...
- Bjarne
Comment #11
margae commentedThanks to Vjordan for contributing the print.css file!
The stylesheets for the new Drupal 6 version have been revised from ground up and I also included a print.css file into the new version. I hope that it works well.
There are no actual plans to revise the Drupal 5 version and so I think that this issue can be closed.
However I invite you to reopen it if you think that corrections for the Drupal 6 version are necessary.