I need to custom watermark pdf documents in Alfresco based on current user. I need to achieve this both in preview and download versions. Is that possible in Alfresco?
1 Answers
There is no such mechanism out of the box in Alfresco but you could implement your requirements using the extension points and APIs:
- Custom Repository Action e.g. to create a pdf overlay / watermark with action parameters and save the result back into the same node. There are several java libraries (e.g. iText) you could use in your action code to manipulate pdfs. You could either pass the watermark text to the action as parameter or you read the required context like current username from the context. More advanced: You could define a selectable freemarker template to generate the watermark text which would make your action more generic/flexible.
- Behavior Policies which listens on specific conditions like onContentUpdate of a specific document type.
- Instead of Behavior Policies you could configure a folder rule to call your custom action.
Once a user creates a new or modifies an existing doc in Alfresco which is catched by the behavior filter or folder rule you could call that just created watermark action. If your requirement is that noone should be able to read the pdf without watermark, you could even run that action in the same transaction.
Previews/thumbnais (renditions) are generated from the main document and if your action modifies the main document the renditons will be regenerated.
Just for the completeness: Alfresco has a Content Transformer Engine and you could implement your own custom T-Engine to watermark PDFs which then is being used in your behavior code but a custom repository action would be more straight forward and additionally supports sync execution in the same transaction.

- 2,488
- 11
- 12
-
My issue would be that I want watermark based on the consumer/reader role and not based on uploader. I need conditional watermark based on reader. – Jagan Veeraraghavan May 22 '23 at 10:56
-
My current approach. ---- - Rule triggers java action. Java action creates multiple child nodes each with different watermarks and different permissions. - But I dont know how to use them in preview/thumbnail/download option based on current logged in user – Jagan Veeraraghavan May 22 '23 at 11:40
-
ah - now I understand your requirement. A user specific transformation based on the *reading* user is not supported by Alfresco's rendition service. The only way I see is to write an interceptor on read content which then needs to transform the pdf on the fly if some conditions are met. – Heiko Robert May 30 '23 at 15:23