My users request that they can print out web pages, so I'm planning to include a CSS file specifically for printing through the media="print" tag. The Alfresco documentation does not explicitly mention the availability of such a file, so I guess I need to include it manually.
Is there an extension point that allows me to link an additional CSS file, perhaps even in a general per-theme way?
in Alfresco 4 you should be able to do this via a Surf Extension Module that is keyed to your theme (via evaluator) and which customizes the /org/alfresco/components/head/resources component to inject CSS imports into the markup regions.
However, I do not know how to create a java class that is called during rendering and that injects a CSS file (with media tag). Do I need to call it from the evaluator?
please also read the other posts from Davids blog - this should hopefully help you see things a bit more clearly. For the approach I outlined you need to implement a evaluator Java class that implements ExtensionModuleEvlauator and checks the current theme. For the injection part, you need to configure a "customization" which targets the web script I mentioned and implement a small FTL template that renders the stylesheet-import code (HTML) using a @markup macro-call.
it took longer than I wanted, but I'd like to share the solution with the community. I packaged it in form of an AMP so that everybody could benefit from it.
I decided to skip the evaluator part at first and include a general print.css file. It comes with some sane defaults and looks quite nice. Next item on the TODO list is to actually introduce one, but let it check whether a theme-specific print.css override exists and apply that on top of the default style sheet.