poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joe Dente" <jde...@21technologies.com>
Subject 3rd PowerPoint Slide is Corrupt
Date Wed, 20 Jan 2010 17:20:03 GMT
Hi,

 

I'm using the POI project to generate some PowerPoint slides. It works
fine until I generate the 3rd slide for my slide deck, which ends up
being corrupted every time. The first time my program runs it creates a
new slide deck and adds a single slide to it. After that, every time the
program runs it grabs the slide deck generated during the first run and
appends a single slide to it. After the first run of the program the
slide deck is fine. After the second run it is fine as well. The third
run generates a corrupt slide every time. For testing purposes I changed
my program so that all 3 runs of the program are generating the
identical blank slide and yet this corruption still happens, so it does
not appear to have anything to do with my slide contents. I am following
the code samples given on the POI website under "Shapes How To":

 

To create the slide deck during the first run:

SlideShow ppt = new SlideShow();

 

To connect to an existing slide deck during subsequent runs:

SlideShow ppt = null;

File pptFile = new File(pptFileName);

if(pptFile.exists()) {

    if(pptFile.canWrite()) {

    //construct the ppt from an existing file

       ppt = new SlideShow(new FileInputStream(pptFile));

    } else {

       throw new IOException("Unable to write to the PowerPoint file '"
+ pptFileName + "'");

    }

}

 

To add a blank slide to the slide deck (nothing fancy here):

Slide slide = ppt.createSlide();

 

To save my slide deck after adding a slide:

FileOutputStream out = new FileOutputStream(pptFileName);

ppt.write(out);

out.close();

 

This all seems very straightforward and so I am not sure why the third
slide is always corrupted. Also, if I use my program to generate 2
slides and then I add a third slide through PowerPoint, I can continue
adding slides to the slide deck without any corruption. I can also
create a blank slide deck through PowerPoint and then use my program to
append blank slides to the deck and no corruption happens. So this leads
me to believe it has something to do with the saving of my PowerPoint
slide deck, since whenever I save it through PowerPoint the corruption
does not occur.

 

I appreciate any help.

Thanks in advance.

Joe


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message