Let’s see how to create a custom action to rotate pdf files. We will use the library pdfBox for which Alfresco
already depends. The result will be display in the Share UI:
Config:
Alfresco Community 5.0.c
Fedora 20
Maven 3.2.3
Maven SDK 2.0.0
Intellij Idea 14
1. Repository
a. Create action
The action itself is quite simple. It takes only one parameter to tell which direction you want to rotate.
b. Spring context
You need to register the bean in the spring context. The id of the bean will re-used later to call the action. Notice
the parent action-executer.
2. Share
a. Share custom config
On the share side, most of the work is done in the share-config-custom.xml. We will define two actions, one to rotate
clockwise and
one to rotate counter-clockwise. At the end, we add the actions in the document details page.
We will see next how to add labels, evaluator and icons.
b. Labels
It looks nicer with labels so I added these ones to my properties:
c. Evaluator
We need an evaluator to make the actions appear only for pdf. An is easy way is to re-use an out of the
box evaluator which returns true if it matches one mimetype from a predefined list (for us the list will
be only pdf).
To do so add this bean in your share spring context.
d. Icons
Finally the icons:
You can probably find better. The most important is where to put them, in the right place:
custom-share-apm/src/main/resources/META-INF/components/documentlibrary/actions