Aspose.Powerpoint (java) clone single slide to new presentation

I’m not used to java, but i’m struggling to do my best. I’m trying to extract all the slides from a presentation into individual presentations with one slide apiece. The problem is that how I’m doing it it just seems to give corrupted presentations (and sometimes throws an “null” error). I know that the original ppt has a master template. I assumed that cloneSlide() would copy the master as well, but not sure. I was wondering if someone could just give me some pointers on how to do this (kind of from the beginning), maybe lay out some steps. It would be most appreciated. Thanks so much.

-Dan

Dear Dan,

The most possible reason of “null” error is you don’t have JAI and JAI-IO libraries installed.
Another thing is java version of Aspose.PowerPoint sometimes has problems when clones slides with images in DIB format (shapes filled with pattern).
DIB images will be fixed on the next week.

Example how to clone each slide to separate presentation:

FileInputStream fis = new FileInputStream(new File(“demo.ppt”));
Presentation pres = new Presentation(fis);

for (int i = 1; i <= pres.getSlides().getLastSlidePosition(); i++) {
fis = new FileInputStream(new File(“demo_empty.ppt”));
Presentation epres = new Presentation(fis);
TreeMap temp = new TreeMap();
pres.cloneSlide(pres.getSlideByPosition(i), epres.getSlides().getLastSlidePosition() + 1, epres, temp);
epres.getSlides().remove(epres.getSlideByPosition(1));
FileOutputStream fos = new FileOutputStream(new File(“target” + i + “.ppt”));
epres.write(fos);
}

demo.ppt - source presentation with slides
demo_empty.ppt - presentation with one empty slide

I originally tried to do just about the same thing while experimenting with the software, it gave me the same error that this gives me, it returns “com.aspose.powerpoint.W” when it tries to write the file, this slide has a collection of graphics on it, it may be related to the problem you mentioned earlier about DIB images. I was wondering what might cause this error since i’ve seen it a few times now. Also if you might have any suggestions on why this is occuring it would be of much help. Thanks for the initial help, I realy appreciate it. Thanks,

Dan

I also get a “Unable to render RenderedOp for this operation” error on a slideshow. Thanks for your help.

-Dan

Dear Dan,

“RenderOp” error is because of DIBs. We have fixed it in 1.1.4 version. Please update.

Could you send me your source presentation where exception was thrown from com.aspose.powerpoint.W function?.

I have attached the presentation, it says it breaks on slide 3 when it gives the error.
Thanks for all your help,

Dan

Dear Dan,

Please check 1.1.5 Java hot fix.

I really appreciate everything you’ve helped with. But I do have one more question. My other assignment is to put powerpoint presentations together from a list of individual presentations with a single slide in them. I have this working, the only issue is that when adding a long list of presentations, because each one is loaded individually, it takes up lots of memory and is slow. Any suggestions? It’s driving me mad, specially since java doesn’t have a “delete” as C++ does… Here is basically what i’m doing now:

Open up first presentation
For all other presentations:
Add slide to first presentation.
Write final presentation to new file.

I’ve even tried to force garbadge collection, but it doesn’t help (much).

I would really appreciate any suggestions, it’ve gotten up to 40-50 megs of memory at points and it’s taken in excess of an hour to do ~70 slides.

-Dan

Dear Dan,

Yes, it use much memory because presentations loaded and unpacked directly in memory.
I just tryed to open presentation with 193 slides (~75Mb) and run your slide copying.
Each slides has large images, text, charts and etc.

About 300Mb of memory was allocated. But it worked quickly enough.
20 slides were copyed in 3 seconds (with time for presentation opening).

Looks like here is another problem. I found presentation with images (png and jpeg)
which can’t be opened with JAI library (ThreadSafeOperationRegistry exception,
probably it’s a bug of JAI).
We will rewrite image processing on this week to avoid any image manipulations.
I think it will increase speed and little reduce memory usage.

I am curious how yours runs in 3 seconds… (this is the merging of X presentations with 1 slide each right?) Mine gets exponentially slower as I merge more and more slides into a single presentation. Maybe you could post your code for this, I haven’t got mine to run nearly as quickly. Thanks,

-Dan

Dear Dan,

The code is absolutely the same as I wrote before in this thread.
My configuration: P4 1.7Ghz, 1Gb, WinXP,
430Mb of memory available before program start.
JVM run with -Xmx500M parameter.

I am also curious how the list of slides are stored in memory; it seems that the longest delay is when cloneslide is called and it appends the slide to another presentation with many slides.
-Dan

Ok, i think i’ve found the issue, the slides that are made with my original tool the one that breaks up a presentation into individual slides, makes inefficient slides for my second tool which puts them back together again. I tried the same slides cut apart by hand and it runs much (much) faster… i’m not sure why, the file sizes of the ones done by hand are much larger too, the only noticable difference is that the ones done by hand are detached from the master template. I’ll do some more testing to try and figure out why, but it’s drastically more efficent… (4sec for merging 20, compared to 33 seconds for the same)

-Dan

Dear Dan,

Yes, you are right. CloneSlide is longest operation.
ppt file has too much cross linked records and all of them must be updated.
For example, to clone one slide all shapes on all slides in target presentation must be scanned twice.
Also copying images takes much time. To avoid images dublicating and probably because of using JAI.

Please check my post:
https://forum.aspose.com/t/110055

I’m not exactly shure how applicable that other thread is… but anyways, I know this has been posted elsewhere, but I haven’t seen much of an answer… I am looking to be able to detach a slide from the slide master, and keep the neccissary formatting… if this really cannot be done as of yet I’ll have to find a workaround, but it would be soooo great and timesaving. Thanks,

-Dan

Slides can’t exist without any master.
Teoretically it’s possible and I experimented with it but different MS PowerPoint versions
show such slides with different unpredictable effects.
Masters in ppt are small enough and not take much time to copy.

The issue that I find though is that I am merging slides together which may have different masters, and unless the reciepient of the merged file has Powerpoint 2003, it won’t open. I’m trying to find a way to be able to make slides become stand alone, i.e. have correct formatting and background not inherited from the master. If there was a way to do this I can figure the master thing out. Thanks for your help again,

-Dan

Also, does cloneslide copy over notes? It gives me blank notes when i try and use it. It gives me a null error when I try and copy them over manually paragraph by paragraph, using

for(int w=0;w<slide2.getParagraphs().size();w++) {
slide2.getNotes().getParagraphs().add(slide1.getNotes().getParagraphs().get(w);
}

Any Ideas?

Thanks,

Dan