Hi,

I still have the problem, Sylvian described. I use Apache POI v3.7-20101029.
I can't open the PPT-File (MS Office 2003 and 2007).
I tried with the same code, Patrickolee posted:

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.model.TextRun;
import org.apache.poi.hslf.usermodel.SlideShow;

public class App {
    public static void main(String[] args) {
        try {
            SlideShow ppt = new SlideShow(new
HSLFSlideShow("./src/main/resources/test.ppt"));
            Slide[] slides = ppt.getSlides();
            for (int i = 0; i < slides.length; i++) {
                TextRun[] text = slides[i].getTextRuns();
                for (int j = 0; j < text.length; j++) {
                    if (text[j].getText().contains("[SYSDATE]")) {
                        text[j].setText("REPLACED_DATE");
                        System.out.println("replaced date!" +
text[j].getText());
                    }
                }
            }
            writeFile(ppt);

        } catch (Exception e) {
            System.out.println("Problem with slide show " + e.getMessage());
        }
    }
    private static void writeFile(SlideShow slideshow) throws
FileNotFoundException, IOException {
        FileOutputStream fos = null;
        try {
            File outputFile = new File("output.ppt");
            fos = new FileOutputStream(outputFile);
            slideshow.write(fos);
        } finally {
            if (fos != null) {
                fos.close();
                fos = null;
            }
        }
    }
} 

And also, if text length is the same it works fine, but if not, it doesn't
work.
What's the problem? I thought the bug is fixed since v3.2

--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Powerpoint-modifying-text-causes-error-Powerpoint-can-t-read-this-text-tp2298821p4288724.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]

Reply via email to