Pretend I have items that are stored as text in the repository, but when the user clicks to download the file, I want to automatically transform the content to PDF.
How can I achieve this "on-the-fly" transformation on the way out of the repository?
The easiest way to do this is to use a rule to transform the content on upload. And then your users download the PDF.
If each user needs their own copy of the PDF, for example if it is watermarked in some way, then you need to inject your transformation code into a content reader.
Cheers for that, I will look into the content reader - can you point me at an example in the Alfresco codebase? Is there any documentation for extending one?
We did this for a project. When a user downloads a content it does a custom transformation and applies watermarking and PDF encryption on the fly. Create and configure a custom download servlet to do this and use that as the download link. Please not however, that there is a performance implication to this. Doing transformation on the fly isn't going to scale very easily.