DCTM:CTS Create pdf rendition

code to create rendition

IDfSysObject obj=(IDfSysObject)session.getObject(oid);

            IMediaProfile[] profiles = null;
            IProfileService profService=(IProfileService)client.newService(IProfileService.class.getName(), manager);
            profiles = profService.getProfiles(session,"msw8",oid.toString(), null); 
            IMediaProfile supportedTransformation =null;

            for(int i = 0; i < profiles.length && supportedTransformation == null; i++) {  
                if(profiles[i].getObjectName().equals("custom_document_to_pdf")) {  
                    supportedTransformation = profiles[i]; 
                } 
            } 

            ICTSService ctsService=(ICTSService)client.newService(ICTSService.class.getName(), manager);
           
            if(ctsService.isCTSServiceAvailable(session)) {
                ICTSRequest request = (ICTSRequest)ctsService.getNewTransformRequest(session);
   
                request.setSourceObjectId(oid.toString()); 
                request.setSourceFormat("msw8");           
                request.setPriority(1);               
                request.setParameters(supportedTransformation.getParameters()); 
                request.setMediaProfileName("custom_document_to_pdf"); 
                request.setMediaProfileLabel("Convert to pdf");  
                request.setTargetFormat("pdf");  
                request.setTargetPage(0);  
                request.setTargetPageModifier("");  
                request.setSourcePage(0); 
                request.setSourcePageModifier("");  
                request.setMediaProfileId(supportedTransformation.getObjectId().getId()); 
                request.setTitle("TestDocPDF");  
                request.setLocale(Locale.getDefault());  
                request.setVersionUp(true);  
                request.save();
               
                System.out.println("\nTransform Request " + request.getObjectId());
                System.out.println("Is transform request valid? " + request.isValid());
               
                boolean notifyUser = false;
                boolean synchronizeCmd =false;
                boolean deleteOnCompletion = true;
               
                System.out.println("Submitting request for transformation...");
                ctsService.submitRequest(session, request, notifyUser, synchronizeCmd, deleteOnCompletion);
                System.out.println("Submitted request for rendition");

Leave a Reply

Your email address will not be published. Required fields are marked *