POI does remove unused parts when removing slides. A media part can be
referenced by multiple slides and such compaction should be done when
writing slideshow, not when removing slides.


The code to compact pptx files and remove unreferenced media parts can
look as follows:

        List<PackagePart> mediaParts =
pptx.getPackage().getPartsByName(Pattern.compile("/ppt/media/.*?"));
        for(PackagePart part : mediaParts){
           // TODO: check if this media part is referenced by other
slides and remove if it is not
            if(unused) {
                pptx.getPackage().removePart(part);
            }
        }


Yegor

On Tue, May 1, 2012 at 8:05 PM, sp0065 <[email protected]> wrote:
> I am looking for a way to compact/shrink pptx files that are generated as a
> results of removing all slides but one slide with slide.removeSlide(X). As I
> mentioned, size of the result files is almost the same as the size of the
> source presentation file because unnecessary images used in the removed
> slides were not removed from the file (ppt\media).
>
> When I opened one-slide-file in PowerPoint and Saved As, file was compacted
> and unnecessary images were removed. Can I do "Save As" programmatically
> with Apache POI by adding some operation to my program?
>
> Thank you.
>
> --
> View this message in context: 
> http://apache-poi.1045710.n5.nabble.com/How-to-split-input-pptx-file-into-a-set-of-single-slide-files-tp5631543p5678348.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to