AnsweredAssumed Answered

copy pdf content

Question asked by francix on Mar 24, 2010
Latest reply on Mar 25, 2010 by francix
Hello, I'm newbie in Alfresco and I'm trying to code a simple script to make a content versioned into an alternate space.

I use the code of the examples
http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook#Create_Backup_of_a_Document_And_Log_Doc_Properties
and
http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook#Create_Document.2C_Make_it_Versionable.2C_Modify_It

And it works fine, but with pdf files mi versioned nodes are blank pages. I think I'm doing something wrong in the copy content process, but I don't know what could it be.

I'm using Alfresco community 3.2 and this is my script:


if (document.isDocument){

   var targetNode = space.childByNamePath("targetNode");
   if (targetNode == null && space.hasPermission("CreateChildren")){
      targetNode = space.createFolder("targetNode");
   }
   
   if (targetNode != null && targetNode.hasPermission("CreateChildren")){
      var docObsoleto = targetNode.childByNamePath(document.name);

      if (docObsoleto == null){
         docObsoleto = document.copy(targetNode);
         docObsoleto.addAspect("cm:versionable");
      }
      if (docObsoleto != null){
         if (docObsoleto.isVersioned)         {
            var workingCopy = docObsoleto.checkout();
            workingCopy.content = document.content;
            docObsoleto = workingCopy.checkin('Old version');
         }         
      }
   }
}

Thaks in advance

Outcomes