We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Merging multiple presentation into one presentation

Hi ,
I am using license version of aspose slides 16.8.0.In my project I am using multithreading for generating multiple presentations and then i am merging all presentation into one target presentation so All presenation created successfully but merging all these presentation into one is taking too much time and after some time it give heap space error using addClone method.

Please find below code snippet

    List<String> presentationName=new ArrayList<String>();

    IPresentation srcIPresentation=null;
    IPresentation targetIPresentation=   new com.aspose.slides.Presentation(presentation.getTemplatePath());
    ISlideCollection targetSlideCollection=targetIPresentation.getSlides();

    for(int a=0;a<presentationName.size();a++)
    {
    
     int presentationSaveFormat = presentation.getPresentationSaveFormat();
 String presentationDestPath = "C:\\Users\\C\\Desktop\\childPresentation\\" +presentationName.get(a) + "."
 + PresentationSaveFormatEnum.getEnumNameByFormatCode(presentationSaveFormat);
     
     srcIPresentation= new com.aspose.slides.Presentation(presentationDestPath);
     ISlideCollection  childSlide=srcIPresentation.getSlides();
     int childSize=childSlide.size();
    
    for (int k = 0; k < childSize; k++)
    {
     ISlide srcSlide =childSlide.get_Item(k);
     targetSlideCollection.addClone(srcSlide);
    }
    
    }


    int presentationSaveFormat = presentation.getPresentationSaveFormat();
 String presentationDestPath = presentation.getPresentationDestPath() + presentation.getPresentationName() + "."
 + PresentationSaveFormatEnum.getEnumNameByFormatCode(presentationSaveFormat);
 
 targetIPresentation.save(presentationDestPath, presentation.getPresentationSaveFormat());  

My requirment is generation total 2000 slides.
i am taking batch of 100 and creating one presentation with 100 slide
like that way 20 presentation created fine.
but merging and saving 2000 slides target presentation taking more time.

So is there is another faster alternative for merging presentation or is this possible for parallel execution of slide generation as our client demands to generate 2000 slides in approx 2mins
Kindly reply asap.
Thanks

@Rutuja,

I have observed the statistics and information shared by you. First of all, I like to suggest you to please try using Aspose.Slides for .NET 17.8 in your application and see if the issue gets reproduced. Also, you are using a huge number of slides (2000) in your application which would certainly take some time. Moreover, it will also depend on how much content is there on slides. The content like multimedia, images, tables and charts and certainly adds overhead. As far as API performance in concerned processing 2000 slides in a couple of minuets is not really a performance issue. I also suggest you to use x64 assembly of Aspose.Slides as well in your application to accommodate huge presentation decks.

However, still if you like us to assess if the statistics shared by you are some performance constraints or not then share a working sample project along with source presentaion data that we may investigate further on our end.

Hi Mudassir,

As you suggest we are using Aspose.Slides for 17.8 java stiil no improvement in performance.I tried another alternative below is code snippet.

        IPresentation srcIPresentation=null;
        IPresentation targetIPresentation=   new com.aspose.slides.Presentation(presentation.getTemplatePath());
        ISlideCollection targetSlideCollection=targetIPresentation.getSlides();
        
        ISlide[]  islide=targetIPresentation.getSlides().toArray();
        islide=new ISlide[10000];
        int index=0;
        
        for(int a=0;a<presentationName.size();a++)
        {
        
        	int presentationSaveFormat = presentation.getPresentationSaveFormat();
	    	String presentationDestPath = "C:\\Users\\C-AnkitaB\\Desktop\\childPresentation\\" +presentationName.get(a) + "."
	    		+ PresentationSaveFormatEnum.getEnumNameByFormatCode(presentationSaveFormat);
        	
        		srcIPresentation= new com.aspose.slides.Presentation(presentationDestPath);
        		ISlide[] vc=srcIPresentation.getSlides().toArray();
        		
        
	       for (int k = 0; k < vc.length; k++)
	        {
	      
	    	   islide[index]=vc[k];
	    	   index++;
	        	
	        }
	        
        }

Is there any way to convert ISlide[] to ISlideCollection object so my problem could solve.
because add addClone() method taking 3 min for just cloning child slide and merge into final one and using .toArray() approach takes 1 min .so can u tell me is there any way to convert ISlide[] to ISlideCollection.

@Rutuja,

I have observed the sample code shared by you and like to share that you can copy the slides in presentation slides collection only using Slide clone method. The sample code that you have used in your previous code us inappropriate.

As far as your following comments are concerned:

There is no method to convert array of ISlide[] to ISlideCollection. You need to use slide cloning to clone individual slides from ISlide[] to ISlideCollection. As far as verification of performance issue is concerned, I request you to please share the source presentation files, machine specification and Java details on your end. We will be able to help you further on provision of requested information.