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

Free Support Forum - aspose.com

Trouble with cloning and thumbnails with certain slides

Hello,

We are having some trouble with some of the slides we’re processing with Aspose.Slides for Java. We have a file “Non-MD-MM Mandatory Deck.ppt” which I’m attaching. We try to split it into one ppt file per slide, and this usually works but on this deck slide 17 fails with an exception com.aspose.slides.PptEditException: Slide cloning error. That is the first problem.

The 2nd problem is that when we get thumbnails for slides 8, 12, and 16, the images are missing some of the graphics from the original slides.

Here’s the code we use to split the ppt:
Presentation p = new Presentation(new FileInputStream(inputFile));
LOG.info(“file has " + p.getSlides().size() + " slides”);

for (int i=0; i<p.getSlides().size(); i++) {
Slide slide = p.getSlideByPosition(i+1);
if (slide!=null) {
LOG.info("saving slide " + (i+1));
TreeMap map = new TreeMap();
Presentation newPresentation = new Presentation();
p.cloneSlide(slide, 1, newPresentation, map);
newPresentation.getSlides().removeAt(0);
File targetFile = new File(targetDir, baseName + “-” + (i + 1) + “.ppt”);
newPresentation.write(new FileOutputStream(targetFile));
newPresentation = null;
}
}

And here’s the code we’re using to get the jpg’s:

Presentation p = new Presentation(new FileInputStream(inputFile));
Slide s = p.getSlideByPosition(1);
BufferedImage slideImage = s.getThumbnail((float)2.0, (float)2.0);
File outputFile = new File(targetDir, baseName + “.jpg”);
LOG.info("writing to " + outputFile.getName());
ImageIO.write(slideImage, “jpg”, outputFile);

PPT and jpg’s attached.

Thanks!

Greg

For your second question, please see this post. Does it help?

http://www.aspose.com/Community/Forums/82874/ShowThread.aspx#82874

Hello-

So you think if I add the Metafiles component, Aspose.Slides will be able to export the graphs to jpg? I think the graphs are embedded Excel object, does Metafiles work with these?

Thanks again,

Greg

Hello-

Well I downloaded Metafiles, and the slides where the graphs were being lost before are now working, thank you for the pointer to that component. Unfortunately, I’m still getting the exception on slide 17 of that presentation (com.aspose.slides.PptEditException: Slide cloning error.). Have you had any luck tracking that down?

Greg

I have done a little change in your code. You should not use size() method of Slides, instead use getLastSlidePosition() method. The reason being is Slides also contains title masters besides normal slide.

int sldCount=p.getSlides().getLastSlidePosition();

for (int i=0; i<sldCount; i++) {

Slide slide = p.getSlideByPosition(i+1);

if (slide!=null) {

TreeMap map = new TreeMap();

Presentation newPresentation = new Presentation();

p.cloneSlide(slide, 1, newPresentation, map);

newPresentation.getSlides().removeAt(0);

File targetFile = new File(targetDir, baseName + "-" + (i + 1) + ".ppt");

newPresentation.write(new FileOutputStream(targetFile));

newPresentation = null;

}

}

I am also getting error on slide 17, I have reported it for a fix.

Thank you for getting back to me on this, I will make that change in my code. How long does it usually take for something like this to get fixed when you report it for a fix? I am just asking so I know what to tell my client when they ask when this will be fixed. Thanks again,

Greg

Normally, Aspose.Slides with new bug fixes is released every weekend. So you can expect it on next weekend.

I will inform you by posting here and you can also check for new fixes here.

I am getting the following error too when i was trying to clone the slides with the following code.

com.aspose.slides.Presentation part = new com.aspose.slides.Presentation(mv.getFileBlob().getBinaryStream());

com.aspose.slides.Slides slides= part.getSlides();

TreeMap ids = new TreeMap();

for(int s =0;s<slides.getLastSlidePosition();s++){

ids.clear();

preso.cloneSlide(part.getSlides().get(s),preso.getSlides().getLastSlidePosition()+1,preso,ids);

}

java.lang.Exception: com.aspose.slides.PptEditException: Slide cloning error.
at com.cisco.ibsg.cbk.business.BusinessFacade.assemblePresentation(BusinessFacade.java:775)
at com.cisco.ibsg.cbk.actions.DownloadPresentationAction.execute(DownloadPresentationAction.java:47)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at com.cisco.ibsg.cbk.framework.CustomRequestProcessor.process(CustomRequestProcessor.java:106)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:595)
Caused by: com.aspose.slides.PptEditException: Slide cloning error.
at com.aspose.slides.Presentation.cloneSlide(SourceFile:1371)
at com.cisco.ibsg.cbk.business.BusinessFacade.assemblePresentation(BusinessFacade.java:757)
... 22 more
Caused by: java.lang.NullPointerException
at com.aspose.slides.Presentation.cloneSlide(SourceFile:1349)

Dear chand,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.Slides for JAVA.

You should pass a new TreeMap object, no matter you clear it.

Also, you need to use cloneSlide method of correct presentation.

Further, your loop should start from 1 till getLastSlidePosition

The code will look like this.

com.aspose.slides.Presentation preso= new com.aspose.slides.Presentation();

com.aspose.slides.Presentation part = new com.aspose.slides.Presentation(mv.getFileBlob().getBinaryStream());

com.aspose.slides.Slides slides= part.getSlides();

for(int s =1;s<=slides.getLastSlidePosition();s++){

part.cloneSlide(part.getSlides().get(s),preso.getSlides().getLastSlidePosition()+1,preso,new TreeMap());

}

Hi,

Thanks for the reply.

I still get the same error after starting the iteration with 1.

Make sure, you follow my all instructions, TreeMap one, the order of presentation in cloneSlide method.

Hi Shakeel,

Thanks for the quick response.I tried changing the presentation and adding the new TreeMap.Now ia m getting the PPT but it's size and order of the slides it is generating is not correct.Please let me know what could be the issue here.

Thanks

Chand

Dear Chand,

To make the size of the slide match the source ppt, you can use Presentation.setSlideSize() method.

e.g

Point pntSize=new Point((int)sourcePres.getSlideSize().getX(), (int)sourcePres.getSlideSize().getY());

targetPres.setSlideSize(pntSize);

You can also change the position of the slide via Slide.setSlidePosition() method.

Also, if your order of slide is incorrect because of one default slide added by Aspose.Slides. You can save its reference and then delete it after your processing is done.

To delete slide you can use Presentation.getSlides().remove(firstSlide) method.

Hi Shakeel,

Thanks for the quick response,i am seeing the following error quite often.Please let me know what could be the root cause for this.

java.lang.OutOfMemoryError: Java heap space
com.aspose.slides.W.(SourceFile:54)
com.aspose.slides.W.(SourceFile:42)
com.aspose.slides.bi.(SourceFile:117)
com.aspose.slides.eB.do(SourceFile:221)
com.aspose.slides.bd.do(SourceFile:81)
com.aspose.slides.Presentation.write(SourceFile:604)

Thanks

Ajay

Hi Shakeel,

Once agian Thanks for the quick response.While cloning the slides i am missing few slides is that could be due to Master Slide also the alignment of the Text images and the order of slides is incorrect.Can you please point me to the correct samples.I will appreciate your support.

Thanks

chand

Hi Shakkel,

I am not able to see the first slide getting cloned and the images too are missing along with the improper alignment.Please advise.

Thanks

Chand

In that case, please provide me your source code and source presentation(s), so that I could see the problem stated by you and correct the code, if there is anything wrong.