Skip to content

Instantly share code, notes, and snippets.

@benheymink
Created April 10, 2024 09:44
Show Gist options
  • Save benheymink/2b06426c3d9374474775c080d40ec00a to your computer and use it in GitHub Desktop.
Save benheymink/2b06426c3d9374474775c080d40ec00a to your computer and use it in GitHub Desktop.
docx4j pptx loading
PresentationMLPackage presentationMLPackage =
(PresentationMLPackage) OpcPackage.load(new java.io.File("src/resources/testPresentation.pptx"));
System.out.printf("Slide count: %d", presentationMLPackage.getMainPresentationPart().getSlideCount());
MainPresentationPart mdp = presentationMLPackage.getMainPresentationPart();
String notesFromSlide = mdp.getSlide(0).getNotesSlidePart().getContents().toString();
System.out.printf("Slide 1 notes: %s", notesFromSlide);
@benheymink
Copy link
Author

Yes, that works (returns the XML). I'd then need to parse that XML correctly, I was looking for a lovely convenience feature to handle all of that for me :-) - i.e to get just the text contents of the notes, or to update the text of the slide notes. I'll keep digging...

(Thanks for the help btw!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment