20050323

PDF vs CSS printing

Having just spent the last few weeks setting up a FO based print solution for an enterprise architecture (SoA + JCA), and going through the hoops required to get it working with plugin branding and other dynamic stuff, I finally had time to return to polishing the final stages of my new look personal website. [I do have other parts to my life, but I left those out]

I generate the website, and for a while I used Forrest and other similar technologies that created a pukka pdf for every page, but the pdf templates were lame and hard to improve without deep FO knowledge. I now have that knowledge, but I wanted to find an easier way.

The main argument used for requiring PDF is that of security, because in theory a PDF document is immutable. In practice they are not, but they are a lot harder to change than almost any other electronic document format I know. The second reason is portability, i.e. that the document will look the same on all platforms. Ignoring the security aspects, the portability aspect is what I am getting at here.

The web is increasingly portable, standards compliant browsers and better formats like CSS2 and XHTML are making life easier. One such improvement is the 'media' type of CSS layers. And this is the technique that I have employed for my website. The 'print' media type is used to turn on and off the visibility of certain divs and spans to make a printable version. Other more subtle changes like wrapping code blocks in the printed form, but scrolling them in the online format, make the whole distinction cleaner.

So I thought: why don't companies who want you to print their material supply CSS based printing instead of the costly to develop and cumbersome PDF files? The client for the enterprise FO solution can sleep soundly because they required the PDF anti-tamper support, but very few purposes need this feature. But FO processing is relatively slow and resource hungry (especially Apache FOP) and client side processing is much more server friendly.

I can only assume that your average web technical architect these days has not kept up with the advances in CSS over the last few years. Shame, because one of the advantages of using media typed CSS is the easy integration of handheld, kiosk and mobile clients. The rebadging or 'white label' capabilities of CSS is also much simpler because of CSS support for multiple inheritance of properties of elements (one of the few areas of less than 100% support though).

1 comment:

Lewis E. Moten III said...

Half the time I get really ticked off with sites that only have printable content in PDF. I usually end up selecting the specified text that I want printed and then hit "Print Selected".

As far as CSS goes - it is a lot of fun. I had been doing that off and on for about 6 years now. I am suprised at the lack of knowledge by many web programmers when asked about this feature.

Maybe you and I are just a little bit ahead of the game.