AnsweredAssumed Answered

Custom action for create PDF

Question asked by sebbri on Jul 12, 2016
Latest reply on Jul 13, 2016 by sebbri
I want to create an action to allow the user to create a PDF document from another document ( eg DOCX ).

I took a sample found on this forum :

Step 1 : I created un custom action custom-action-services-context.xml

<?xml version='1.0' encoding='UTF-8'?>
      <bean id="transform-to-pdf-action" parent="script">
                <property name="scriptLocation">
                        <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation">

Step 2 : the JS script (transformToPdf.js) :
This script created a PDF document with a property containing the name of the original document and version.

var name =["cm:name"];
var version =["cm:versionLabel"];
newdoc = document.transformDocument("application/pdf");["gen:Version"] = name + " ("+ version +")";;

Step 3 : share-config-custom.xml :

<config evaluator="string-compare" condition="DocLibActions">
                <!– Transfor Document To PDF –>
                <action id="transform-to-pdf" type="javascript" label="Transformer en PDF">
                        <param name="function">onActionFormDialog</param>
                        <!– Additional parameters for onFormDialog function  –>
                        <param name="itemKind">action</param>
                        <param name="itemId">transform-to-pdf-action</param>
                        <param name="mode">create</param>
                        <param name="destination">{node.nodeRef}</param>
                        <param name="action">transform-to-pdf-action</param>
                        <param name="successMessage">Succcès : le document PDF a été créé</param>
                        <param name="failureMessage">Echec : Le document PDF n'a pas été créé"</param>
                 <actionGroup id="document-browse">
                         <action index="460" id="transform-to-pdf"/>

It works. But I'm missing something : I would like the user to select the destination folder . I do not find how to add arrige this form.
As it stands, the PDF is created in the same folder.

Please help !

(Sorry for my english)

Merci d'avance