Yep. It most definitely can be done using server-side Java. The iText library is the most popular.
Dong it this way, of course requires a round-trip back to the server to re-produce the content, and you'll need to set the mime-type appropriately.
If you use an MVC framework, such as strut/webworks, you'll find it's easy to implement.
I'm surprised you've had little luck with the
CSS solution. I usually provide a print.
css. Admittedly, it has a long way to go, but the modern browsers provide pretty good
CSS support. No, they can't over-ride printer settings.
Perhaps your print
CSS needs to re-set the margins in use by other style sheets? Make sure your screen styles are limited to the screen media and are not over-riding/complicating anything.