Blogroll
A great source of information for Lotus Domino administrators
Jeff Potts' excellent ECM/Portal blog
Lots of very useful Alfresco articles
| Watermarking PDF Documents with Alfresco |
|
|
|
| Written by Nathan McMinn |
| Monday, 06 September 2010 15:31 |
|
Like a lot of Alfresco users, I spend a lot of time dealing with PDF documents. Invoices, purchase orders, product specifications, documentation and signed authorizations all flow through our Alfresco system as PDFs. Recently I had a need to watermark a subset of these documents, marking them as "official" or "draft" releases. A bit of poking around revealed that there wasn't an open-source, free way to apply simple watermarks to PDF documents in Alfresco. Generis has a solution, but it is a commercial package and provides a lot more functionality than I really need. So, what to do? Extend Alfresco, of course!
Alfresco allows developers to create custom actions that can manipulate nodes in the repository. These actions can then be triggered via a content rule, perfect for my needs. It's pretty simple: a document is added to a space, the content rule is triggered and calls an action that can modify the new document. While I was looking around for PDF tools for Alfresco, I came across Jared Ottley's blog, and specifically his Alfresco PDF Toolkit project. I love to learn by example, and Jared's code was a nice, concise introduction to how custom actions work. With a few days of coding, I was able to add a PDF watermarking action to his existing project. The code has been added to the alfresco-pdf-toolkit project on Google Code. It supports the following features:
You can either build the package from source or download the AMP file here. For those that don't know, AMPs are one of the ways that extensions to Alfresco can be packaged. AMPs are deployed using the Alfresco Module Management Tool. Once you have installed the AMP and restarted Alfresco, you will find a few new actions available. To try out the watermarking action, start by creating a space for inbound PDF documents and create a new content rule for the space. Since this action will only work with PDF documents, set the condition to "Content of mimetype", as shown below:
Select "Adobe PDF Document" from the mimetype list to ensure that this rule is only triggered when a PDF is added.
After you have set the mimetype and clicked "Next", select the "Watermark PDF" action from the list. Click "Set Values and Add" to configure the PDF watermarking action:
The PDF Watermark action requries 5 parameters. The first, the watermark image, is the image that you wish to have applied to your PDF. Most common image formats are supported. The second parameter is the destination. This is the space into which the watermarked PDF will be placed. The watermarked PDF will have the same name as the original, so it probably isn't a good idea to put it back into the same space. Finally, you can select the pages to watermark, the position of the watermark, and whether the mark will be applied above or below the existing PDF content (similar to a CSS z-index).
Once the parameters are set, click OK to save. Finish up the "Add Content Rule" wizard and you are all set. Any PDF documents put into the space will now be watermarked and copied to the destination space you specified.
Additional feature requests are welcome, enjoy! |
| Last Updated on Tuesday, 07 September 2010 13:37 |
About Me

My name is Nathan McMinn. I'm a software engineer, beer geek, wannabe adventurer and genuinely curious guy. Find me on Facebook, Linkedin or Twitter
Latest Comments
- Storing and Retrieving Images ...
Hi, Thanks for your tutorial. it suggestion really... - Alfresco PDF Toolkit - Digital...
It will be very useful, if at one go I can digital... - Integrating Alfresco Content i...
Hola estoy trabajando con el módulo de drupal CMIS... - Integrating Alfresco Content i...
Hola estoy trabajando con el módulo de drupal CMIS... - Calling Web Services from the ...
Nvm - resolved it - needed to restart browser for ...







Comments
Hi,
I experienced the same problem, but I can get rid of this problem by using another method.
Here is the solution:
1) Copy the source code from alfresco-pdf-toolkit link above.
2) Copy iText-5.0.4.jar into 'alf-home\tomcat\web apps\alfresco\W EB-INF\lib'
3) Copy files in 'web\jsp\actions ' into 'alf-home\tomcat\web apps\alfresco\j sp\actions'
4) Compile java source code inside folder src into a jar file then copy it 'into alf-home\tomcat\web apps\alfresco\W EB-INF\lib'
5) Copy files and folders in 'config\alfresco \module' into 'alf-home\tomcat\web apps\alfresco\W EB-INF\classes\alf resco\module'
org.apache.jasper.JasperException : Unable to compile class for JSP:
An error occurred at line: 6 in the generated java file
Only a type can be imported. javax.faces.context.FacesContext resolves to a package
An error occurred at line: 7 in the generated java file
Only a type can be imported. javax.transaction.UserTransaction resolves to a package
...
Hi i install amp:
Module 'org.alfresco.extension.pdftoolkit' installed in 'c:\Alfresco\tom
pps\alfresco.war'
- Title: Alfresco PDF Toolkit
- Version: 0.96
- Install Date: Wed Aug 17 23:40:53 CLT 2011
- Desription: This module adds functionality to manipulate PDFs
No error log.
No "Watermark PDF" action
Alfresco 3.4d
Thank you for your help.
joters
thank you for your reply!
No I could not find the class deployed. I checked the alfresco.log and I found following error message:
ERROR [org.springframework .web.context.ContextLoader] Context initialization failed
org.alfresco.error.AlfrescoRuntime Exception: 10300000 Workflow deployment failed
Could that have something to do with it?
Thanks a lot!
Gigi
If you don't see a "Watermark PDF" action, then the PDF toolkit is probably not installed. Did you get any errors when you applied the AMP? Can you check your patched Alfresco instance and see if any of the classes from the PDF Toolkit (such as PDFWatermarkAct ionExecuter) are present?
thank you for your solution. I wanted to try it out and installed your AMP withe the Module Management Tool and when I use the list function I can se it has been installed successfully. But when I am creating a new rule - there is no "Watermark PDF" Action available.
What might be the problem here?
Thank you for your help.
Gigi
I have a raft of new feature requests coming in, and yours will definitely be on the list. The font features are coming soon.
For the rest, I plan on making the PDF text field Freemarker-friendly (or just allow the selection of a template in the repository). That should allow the inclusion of all the document metadata and provide a few other nice features.
A few feature requests for all your free time (yeah, right... :)
1) Allow other metadata information like version, path (both full and relative to a site document library), decsription, etc.
2) Allow custom metadata.
3) Allow different date formats (including time).
4) Allow smaller fonts (down to 6 pt).
5) Allow bold or italic.
6) Allow regexp strings/replacement.
7) Develop some mechanism to left justify part of a text watermark and right justify the other part.
Thanks again for some nice software.
Bob
RSS feed for comments to this post.