cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure custom transformer

viralshah
Champ in-the-making
Champ in-the-making
I understand that Alfresco currently doen't have provision to add watermark when converting word document to PDF.  Suppose one writes a custom transformer to add watermark to existing PDF.
So it will be like:
Inbound Word->Out of box transformer->PDF->Custom transformer->PDF with watermark

How to configure such a transformer chain in Alfresco as the mime type would be same (i.e. PDF) for source & destination of the custom transformer.
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
Yes that would be a problem, the mime type is not being changed.

Instead you could drive your conversion through the rendition service or a rule.    My first thought is that a watermarked pdf is a rendition.

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
may be you should use another approach for instance:

 <bean id="transformer.PdfBox.TextToPdf"
         class="org.alfresco.repo.content.transform.TextToPdfContentTransformer"
         parent="baseContentTransformer" >
      <property name="explicitTransformations">
         <list>
            <bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
                <constructor-arg><value>text/plain</value></constructor-arg>
                <constructor-arg><value>application/pdf</value></constructor-arg>
            </bean>
         </list>
      </property>
   </bean>

then you check out the code for TextToPdfContentTransformer http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/repository/source/jav...

and see that  in the bottom you have code
PDDocument pdf = null;
        InputStream is = null;
        OutputStream os = null;
        try
        {
            is = reader.getContentInputStream();
            pdf = transformer.createPDFFromText(new InputStreamReader(is));
            // dump it all to the writer
            os = writer.getContentOutputStream();
            pdf.save(os);
        }

and you add code for watermark .
so if you follow this idea maybe it would prove to be good way if I have understand you well.

edwardlobo
Champ in-the-making
Champ in-the-making
I am in a similiar situation to convert image pdf to readable pdf. Upon thinking further I was wondering if the following would be possible

create a new mime called fdf
rename the original.pdf file to original.fdf
run the transformer from source fdf to pdf

I might not need help creating a new mime however how do i rename the file to fdf ?

edwardlobo
Champ in-the-making
Champ in-the-making
can i call mv for instance from a transformer to transform orginal.pdf to original.fdf