cancel
Showing results for 
Search instead for 
Did you mean: 

Custom tranformation

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
Hi i have created tranformation image to pdf with vividata ocr, but

 <property name="transformCommand"> 
        <bean class="org.alfresco.util.exec.RuntimeExec">
 
            <property name="commandMap">
                <map>
                    <entry key=".*">
                       <value>/opt/Vividata/bin/ocrxtr ..${target}  ${source } ….
What I want is to create custom way to add new parameters for istance: ${locale} and so on. is there a known way for this.
6 REPLIES 6

derek
Star Contributor
Star Contributor
Hi,
You can add any number of parameters (${myvar1} ${myvar2}) in the command.  Then add default properties to cover the extra parameter using the transformCommand.defaultProperties property:

   <property name="defaultProperties">
      <props>
      …
      </props>
   …
Inject your transformCommand into a RuntimeExecutableContentTransformerWorker and call execute with an instance of RuntimeExecutableContentTransformerOptions which contains values to substitute into the ${…} parameters.

Regards

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
I faild to understand you, if you could provide mi for a bit more of help: you would notice ${language} param.
how to work from hire, please help.


class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer"
      parent="baseContentTransformer">
      <property name="checkCommand">
         <!–   <bean class="org.alfresco.util.exec.RuntimeExec"> –>
         <bean class="org.alfresco.docassistent.util.CustomRuntimeExec">
            <property name="commandMap">
               <map>

                  <entry key="Linux">
                     <value>/opt/Vividata/bin/ocrxtr -help</value>
                  </entry>
                  <entry key="Windows.*">
                     <value>D:/ocrxtr.bat -help</value>
                  </entry>
               </map>
            </property>
            <property name="errorCodes">
               <value>1,2</value>
            </property>
         </bean>
      </property>
      <property name="transformCommand">
           <bean class="org.alfresco.util.exec.RuntimeExec">

            <property name="commandMap">
               <map>

                  <entry key="Linux">
                     <value>/opt/Vividata/bin/ocrxtr -overwrite=y -out_text_format=pdf
                        -language=${language} -out_text_name=${target} ${source}</value>
                  </entry>
                  <entry key="Windows.*">
                     <value>D:/ocrxtr.bat -overwrite=y -out_text_format=pdf
                        -language=${language} -out_text_name=${target} ${source}</value>
                  </entry>
               </map>

            </property>
            <property name="errorCodes">
               <value>1,2</value>
            </property>
[b]<property name="defaultProperties">
                 <props>
                    <prop key="language"></prop>
                 </props>
                 </property>[/b]
         </bean>
      </property>
      <property name="explicitTransformations">….
         <list>

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
So I do not get that part with RuntimeExecutableContentTransformerWorker , can you explain that to me .
Just to explain, this is  being run from

Map<String, Serializable> actionParams = new HashMap<String, Serializable>();
       actionParams.put("actionName", "transform");
       actionParams.put("transformer", "application/pdf");
Action action = this.getActionService().createAction(actionname);
       action.setParameterValues(repoActionParams);
       System.out.println("START TRANFORMATION");
       this.getActionService().executeAction(action, nodeRef);

there fore I do not get that other part where I replace language value for real value.

PS: please help, because my company need to pay the vividata for the software soon and we need to set this up first.

derek
Star Contributor
Star Contributor
If you are using actions, then the best is to follow the example of the ImageTransformActionExecuter and the beans that surround it, except that you must use your newly-defined transformer and the RuntimeExecutableContentTransformerOptions.  Sorry, there is no predefined action for generalized executables i.e. you will have to write java code.

derek
Star Contributor
Star Contributor
If you have proprietary software that you've bought, you may find that they have Java libraries or even means of connecting to an OCR server.  Have you investigated these options?  Using the command line is fine, but not nearly as neat as having a custom-written transformer that connects to some server or at least uses JNI.

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
Yes but I have not found this information about api. I thing that there is not api in this OCR.
anyway my bosses decided to go on english for now so I do not need to change languages on the fly. hard code will do fine now. I have looked at the example for this it is no so hard to implement with your help. tx .