Hi Team,
During conversion of PPT/PPTX to Image using Aspose Slides for Java the CPU and Memory utilisation goes very high.
CPU goes more that 90%.
Sample Code:
com.aspose.slides.License lic = new com.aspose.slides.License();
try {
lic.setLicense(new FileInputStream(new File("c:/Aspose.Total.Java.lic")));
System.out.println("License File Read........");
} catch (Exception e) {
System.out.println("Exception with license" +e.getMessage());
}
PresentationEx pres = new PresentationEx("c:/file.ppt");
//Accessing a slide using its slide position
SlideEx slide = pres.getSlides().get(0); // as index is starting from 0 for pptx files
//Getting the thumbnail image of the slide of a specified size
BufferedImage image=slide.getThumbnail(1f,1f);
// Set fonts to be scanned for under the specified directory. Do not search within sub-folders.
FontSettings.setFontsFolder("/usr/share/fonts/", false);
//Saving the thumbnail image in jpeg format
ImageIO.write(image,"jpeg","c:/convert.jpeg");
I am using 2.9.3 version of Aspose Slides
Can you please help me with this as are we missing something on the setup part or code part or something else?
Regards,
Asif
Hi Asif,
Thanks for your inquiry. I have observed the issue shared by you and like to share that you are accessing the PPT using PresentatoinEx class. I am afraid the PPT to PPTX conversion support is currently unavialable in Aspose.Slides for Java. Secondly, I also like to add the PPTX presentation are in compressed format and when PresentationEx is instntiated the whole presentation is decompressed and laoded in DOM (Document Object Model). The CPU and memory usage depends upon the size and contents of the presentation. I hope this will clear the concept to you.
I would suggest you to try using Aspose.Slides for Java 2.9.4 and if you are still not satisified then please share the sample presentation along with the complete platform information on your end. Please also share the memory and CPU usage statistics with us as well.
Many Thanks,
Hi Mudassir,
Many thanks for quick response.
The code was for PPTX.
Actually I am facing high CPU usage for PPT and PPTX.
We are trying to run the code for multiple concurrent users.
I am using Multithread for this with 5 thread at a time, and with the CPU goes to 99 %.
With Single thread the CPU goes above 50-60%.
Sample code for PPT:
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.imageio.ImageIO;
import com.aspose.slides.Presentation;
import com.aspose.slides.Slide;
public class TestFile implements Runnable{
public String strFileName;
public TestFile(String strFileName)
{
this.strFileName = strFileName;
}
public void run()
{
testConvert();
}
public void testConvert()
{
try
{
/*PPT To Image*/
/*License
com.aspose.slides.License lic = new com.aspose.slides.License();
try {
lic.setLicense(new FileInputStream(new File("c:/Aspose.Total.Java.lic")));
System.out.println("License File Read........");
} catch (Exception e) {
System.out.println("Exception with license " +e.getMessage());
}
*/
Presentation pres = new Presentation(new FileInputStream(new File("c:/test"+strFileName+".ppt")));
int pageCount = pres.getSlides().size();
System.out.println("File No : "+strFileName);
System.out.println("Page Count : "+pageCount);
//for(int i=1; i<=pageCount; i++){
//Accessing a slide using its slide position
Slide slide = pres.getSlideByPosition(1);
//Getting the thumbnail image of the slide of a specified size
BufferedImage image=slide.getThumbnail(new Dimension(1440,1080));
//Saving the thumbnail image in jpeg format
ImageIO.write(image,"jpeg", new File("c:/File - " + strFileName+".jpg"));
/*PPT To Image*/
}
catch(Exception e)
{
System.out.println(e);
}
}
public static void main(String[] args)
{
try{
ExecutorService executor = Executors.newFixedThreadPool(5);
for(int i=1;i<=5;i++)
{
Thread t = new Thread(new TestFile(Integer.valueOf(i).toString()));
executor.execute(t);
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
I have 5 test file i.e test1.ppt to test5.ppt
Attaching the zip file with all 5 files
We have linux server,Jboss 6, Java 6.
Regards,
Asif
Hi Asif,
I have observed the code snippet and it seems OK. Kindly share the source files as shared by you. I feel you might have missed to share the requested files.
Many Thanks,
Hi Asif,
Thanks for sharing the additional information.
I have used the code snippet shared with the presentation files shared by you and have not been able to observe the reported issue using Aspose.Slides for Java 2.9.4 in both Windows 7 and Ubuntu environment on my end. I dont’t think the issue on your end may be related to Aspose.Sldies for Java as I have not been able to reproduce it on two platforms. For your convenience, I have also share the snapshot of CPU and memory usage for both Windows 7 and Ubuntu environment. I would suggest you to please try using latest avaialble mentioned version of Aspose.Slides for Java.
Many Thanks,
Hi Mudassir,
Thanks for reply.
I am attaching the sanpshot of the CPU which I am getting on this.
We are using altogether a new Server Box for testing this Aspose slides only.We have Red hat Linux Server.
I am using 2.9.3 version for Aspose Slides.
Regards,
Asif
Hi Asif,
I have observed the issue reported in your snapshot. However, before logging issue in our issue tracking system, I would request you to please try using Aspose.Slides for Java 2.9.4 on your end share the snapshot with us for comparison and further investigation. Please also share the Linux server version along with Processor and Ram specifications with us as well. I will really appreciate your cooperation in this regard.
Best Regards,