I'm trying to transfer speaker notes from one powerpoint to another using apache poi, and I can't get an accurate transfer.
After looking around a bit, I couldn't find many resources. I did find this link: How to get pptx slide notes text using apache poi? , and it works in most situations. But when some features such as the slide master are involved in the original pptx, some text that aren't part of the speaker notes are interpreted as speaker notes.
XSLFNotes notes_src = slides_src[i].getNotes();
XSLFNotes notes_dst = ppt_dst.getNotesSlide(slides_dst[i]);
This is all inside a for loop where i is the iteration number. Here I'm getting slide i for the source and the corresponding slide i from the destination file.
for (XSLFShape shape_src : notes_src) {
if (shape_src instanceof XSLFTextShape) {
XSLFTextShape txShape = (XSLFTextShape) shape_src;
for (XSLFTextParagraph xslfParagraph : txShape.getTextParagraphs()) {
Here I'm getting the text from the slide. The if loop below is where I have to start filtering out some "speaker" notes which aren't actually speaker notes (for example, the slide number is somehow interpreted as a note; there's also this copyright symbol printed).
if (!(xslfParagraph.getText().startsWith("" + (i + 1)) & xslfParagraph.getText().length() < 3) & !(xslfParagraph.getText().startsWith("Copyright ©"))) {
for (XSLFTextShape shape_dst : notes_dst.getPlaceholders()) {
if (shape_dst.getTextType() == Placeholder.BODY) {
shape_dst.setText(shape_dst.getText() + xslfParagraph.getText() + "\n");
The statement below is yet another filter; if a feature involving master slides is involved, a weird "click to edit master text styles..." piece of text will be interpreted as speaker notes as well.
shape_dst.setText(shape_dst.getText().replace("Click to edit Master text styles", "").replace("Second level", "").replace("Third level", "").replace("Fourth level", "").replace("Fifth level", ""));
}}}}}}
In short, things that aren't speaker notes are appearing as "notes". There aren't many resources online about this subject; can someone help?