cancel
Showing results for 
Search instead for 
Did you mean: 

Cmis: How to create renditions

richardeb
Champ in-the-making
Champ in-the-making
Hello,


the alfresco cmis interface returns only existing renditions for a document.(e.g a preview) How can I force alfresco to create the renditions files (e.g. the preview) if they don't exist?

Thank you
7 REPLIES 7

kaynezhang
World-Class Innovator
World-Class Innovator
I'm afraid you can not create  renditions using CMIS directly.

richardeb
Champ in-the-making
Champ in-the-making
Oh that are bad news. But maybe I found a solution. I created a folder for all documents that I want to retrieve with cmis. Then I added the following script as a rule (for adding/updating documents) to this folder

//EDIT: script-Update

try
{
   function main()
   {

      var thumbs=document.getThumbnailDefinitions();
      try
      {
         if(contains(thumbs,"doclib"))
            document.createThumbnail("doclib");
      }
      catch(err)  {  }
      try
      {
         if(contains(thumbs,"webpreview"))
            document.createThumbnail("webpreview",true);
      }
      catch(err)  {  }
   }
   function contains(a, obj) {
      if(a.length>0){
         for (var i = 0; i < a.length; i++) {
            if (a == obj) {
               return true;
            }
         }
      }
      return false;
   }
   main();
}catch(err)  {  }


Is this a common solution or do you have a better solution? What about the performance? Ist this code always working(subfolder/edit/update/updates by other scripts/…)?

Thank you

richardeb
Champ in-the-making
Champ in-the-making
Unfortunatly the script doesn't work correct. If I upload a docx file the upload fails. Do you have any solution how to fix this? Thank you

kaynezhang
World-Class Innovator
World-Class Innovator
Ye using  rule on a folder that creates the rendition is a good solution
When creating the object using CMIS will trigger the rule which creates the rendition.

richardeb
Champ in-the-making
Champ in-the-making
Unfortunatly document.createThumbnail("doclib") fails when executed on a docx file.

If the rule is defined as synchron document.createThumbnail("doclib") throws an error that causes a rollback. (I can't prevent/catch this). If I define the rule as async document.createThumbnail("doclib") will never work. (I tested this using the share frotend itself for adding documents)

kaynezhang
World-Class Innovator
World-Class Innovator
please call javascript rendition service api like following

var renditionDef = renditionService.createRenditionDefinition('cm:pdfExport', 'reformat');
renditionDef.parameters['mime-type'] = "application/pdf";
var renditionNode = renditionService.render(document, renditionDef);

richardeb
Champ in-the-making
Champ in-the-making
It works perfect. Thank you very much.