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

Free Support Forum - aspose.com

getThumbnail Method Is Throwing Exception in Parallelism

I am trying to generate the thumbnail parallelly from slides. I am getting below exception at slide.getThumbnail(1f, 1f)

com.aspose.slides.exceptions.ArgumentException: An element with the same key already exists in the dictionary.
at com.aspose.slides.Collections.Generic.Dictionary.addItem(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.pc.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.o6.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.ov.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.apr.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.apr.if(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.char.case(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Theme.if(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Theme.getEffective(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.BaseOverrideThemeManager.createThemeEffective(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.BaseSlide.createThemeEffective(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.char.else(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.char.case(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Background.byte(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.al.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.al.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.char.case(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Background.byte(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.BaseSlide.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Slide.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Slide.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Slide.do(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Slide.for(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]
at com.aspose.slides.Slide.getThumbnail(Unknown Source) ~[aspose-slides-21.1-jdk16.jar:21.1]

Please find below code for reference

        Presentation pptx = loadTemplate(fileName);
        List<Integer> slideIndexList = Arrays.asList(2,3,5,7,9);
        slideIndexList.stream().parallel().forEach(slideIndex -> {
            ISlide slide = pptx.getSlides().get_Item(slideIndex);
            slide.getThumbnail(1f, 1f);
        });

@madhukar.devale15,
Thank you for contacting support.

If I understand correctly, you are trying to use multithreading to convert presentation slides to images. Unfortunately, Aspose.Slides does not support parallel processing for a single presentation instance. Such operations are not safe.

Documents: Multithreading in Aspose.Slides