work with powerpoint slide notes in java

The slide notes are used to add additional information as a reference in the presentations. The presenters add these notes to recall the essential points relevant to their presentations. In this article, you will learn how to manipulation of the slide notes in presentations programmatically. Particularly, the article will cover how to read, add, and remove the slide notes in PowerPoint presentations using Java.

Java API to Work with PowerPoint Slide Notes

In order to work with slide notes, we’ll use Aspose.Slides for Java. It is a feature-rich API that lets you create, edit and convert PowerPoint presentations from within your Java applications. You can either download the API or install it using the following Maven configurations.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>21.3</version>
    <classifier>jdk16</classifier>
</dependency>

Read Slide Notes in a PowerPoint Presentation in Java

The following are the steps to read slide notes in PowerPoint presentations using Java.

The following code sample shows how to read slide notes in PowerPoint presentation using Java.

// Load presentation file
Presentation presentation = new Presentation("presentation.pptx");
// Access notes slide manager
INotesSlideManager mgr = presentation.getSlides().get_Item(0).getNotesSlideManager();
// Read slide notes
INotesSlide note = mgr.getNotesSlide();
System.out.println(note.getNotesTextFrame().getText());

Add Slide Notes to a PowerPoint Presentation using Java

The following are the steps to add slide notes to a PowerPoint presentation using Java.

The following code sample shows how to add slide notes in a PowerPoint presentation using Java.

// Load presentation file
Presentation presentation = new Presentation("presentation.pptx");
// Access notes slide manager
INotesSlideManager mgr = presentation.getSlides().get_Item(0).getNotesSlideManager();
// Add text to the notes
INotesSlide note = mgr.getNotesSlide();
note.getNotesTextFrame().setText("new slide note");
// Save updated presentation
presentation.save("added-slide-notes.pptx", SaveFormat.Pptx);

Remove Slide Notes in a PowerPoint Presentation

The following are the steps to remove the slides notes in PowerPoint presentations using Java.

The following code sample shows how to remove slide notes in a PowerPoint presentation using Java.

// Access notes slide manager
Presentation pres = new Presentation("presWithNotes.pptx");
// Remove notes of first slide
INotesSlideManager mgr = pres.getSlides().get_Item(0).getNotesSlideManager();
mgr.removeNotesSlide();
// Save updated presentation
pres.save("test.pptx", SaveFormat.Pptx);

Get a Free API License

You can request a free temporary license to use the API without evaluation limitations.

Conclusion

In this article, you have learned how to work with slide notes in PowerPoint presentations using Java. The step-by-step guide and code samples have shown how to read, add, or remove slide notes. In addition, you can explore more about the API using the documentation. Alongside, you can post your queries to our forum.

See Also