package com;import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;import com.aspose.slides.ISlide;
import com.aspose.slides.License;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;public class TestPPT
{
public static void main(String[] args) throws FileNotFoundException
{
License license = new License();
license.setLicense("/home/vincent/licenses/Aspose.Total.Java.lic");File templateFolder = new File("src/main/resources/test"); if (!templateFolder.isDirectory()) { System.out.println("Not a folder"); System.exit(1); } TestPPT test = new TestPPT(); test.processDocuments(templateFolder, 50); System.exit(0); } public void processDocuments(File folder, int passes) throws FileNotFoundException { Presentation presentation = null; int presentationNumber = 0; int slideNumber = 0; String path = folder.getAbsolutePath(); String tempPath = path + "/temp/"; for (int i = 0; i < passes; i++) { System.out.println("\nPass number " + (i < 10 ? "0" + i : i)); for (File templateFile : folder.listFiles()) { if (templateFile.isDirectory()) { continue; } System.out.println("\t# Processing template " + templateFile.getName()); if (presentation != null) { for (ISlide slide : (new Presentation(new FileInputStream(templateFile))).getSlides()) { slideNumber++; System.out.println("\t\t# Processing slides: " + (slideNumber < 10 ? "00" + slideNumber : slideNumber < 100 ? slideNumber : slideNumber)); presentation.getSlides().addClone(slide); } } else { presentation = new Presentation(new FileInputStream(templateFile)); slideNumber = presentation.getSlides().size(); } } if (((i + 1) % 10) == 0) { File tempFolder = new File(tempPath); if (!tempFolder.exists()) { tempFolder.mkdirs(); } presentationNumber++; presentation.save(tempPath + "Presentation" + (presentationNumber < 10 ? "0" + presentationNumber : presentationNumber) + ".ppt", SaveFormat.Ppt); presentation.dispose(); presentation = null; System.gc(); } } if (presentationNumber == 0) { presentation.save(path + "Presentation.ppt", SaveFormat.Ppt); presentation.dispose(); return; } else if (presentation != null) { presentation.save(tempPath + "Presentation" + (presentationNumber < 10 ? "0" + presentationNumber : presentationNumber) + ".ppt", SaveFormat.Ppt); presentation.dispose(); } processDocuments(new File(tempPath), 1); return; }
}
ASPOSE.SLIDES for JAVA 15.11.0 is consuming much more memory than expected when slide number goes up
Hi Vincent,
Hi Vincent,