Add, Read and Delete Speaker Notes in PowerPoint in Java

This article demonstrates how to add, read and delete speaker notes in a PowerPoint document using Spire.Presentation for Java.

Add Speaker Notes

import com.spire.presentation.*;

public class SpeakerNotes {
    public static void main(String[] args) throws Exception {
        //Load the PowerPoint document
        Presentation ppt = new Presentation();
        ppt.loadFromFile("Sample.pptx");

        //Get the first slide
        ISlide slide = ppt.getSlides().get(0);
        //Add note slide
        NotesSlide notesSlide = slide.addNotesSlide();

        //Add a paragraph to the note slide
        ParagraphEx paragraph = new ParagraphEx();
        paragraph.setText("Tips for making effective presentations:");
        notesSlide.getNotesTextFrame().getParagraphs().append(paragraph);

        //Add a paragraph to the note slide
        paragraph = new ParagraphEx();
        paragraph.setText("Use the slide master feature to create a consistent and simple design template.");
        notesSlide.getNotesTextFrame().getParagraphs().append(paragraph);
        //Set the bullet type and style for the paragraph
        notesSlide.getNotesTextFrame().getParagraphs().get(1).setBulletType(TextBulletType.NUMBERED);
        notesSlide.getNotesTextFrame().getParagraphs().get(1).setBulletStyle(NumberedBulletStyle.BULLET_ARABIC_PERIOD);

        //Add a paragraph to the note slide
        paragraph = new ParagraphEx();
        paragraph.setText("Simplify and limit the number of words on each screen.");
        notesSlide.getNotesTextFrame().getParagraphs().append(paragraph);
        //Set the bullet type and style for the paragraph
        notesSlide.getNotesTextFrame().getParagraphs().get(2).setBulletType(TextBulletType.NUMBERED);
        notesSlide.getNotesTextFrame().getParagraphs().get(2).setBulletStyle(NumberedBulletStyle.BULLET_ARABIC_PERIOD);

        //Add a paragraph to the note slide
        paragraph = new ParagraphEx();
        paragraph.setText("Use contrasting colors for text and background.");
        notesSlide.getNotesTextFrame().getParagraphs().append(paragraph);
        //Set the bullet and style type for the paragraph
        notesSlide.getNotesTextFrame().getParagraphs().get(3).setBulletType(TextBulletType.NUMBERED);
        notesSlide.getNotesTextFrame().getParagraphs().get(3).setBulletStyle(NumberedBulletStyle.BULLET_ARABIC_PERIOD);

        //Save the document
        ppt.saveToFile("SpeakerNotes.pptx", FileFormat.PPTX_2013);
    }
}

Add, Read and Delete Speaker Notes in PowerPoint in Java

Read Speaker Notes

import com.spire.presentation.*;

import java.io.FileWriter;

public class SpeakerNotes {
    public static void main(String[] args) throws Exception {
        //Load the PowerPoint document
        Presentation ppt = new Presentation();
        ppt.loadFromFile("SpeakerNotes.pptx");

        //Get the first slide
        ISlide slide = ppt.getSlides().get(0);

        //Get the content of notes from note slide
        StringBuilder buffer = new StringBuilder();
        String notes = slide.getNotesSlide().getNotesTextFrame().getText();
        buffer.append(notes);

        //Save to .txt file
        FileWriter writer = new FileWriter("SpeakerNotes.txt");
        writer.write(buffer.toString());
        writer.flush();
        writer.close();

    }
}

Add, Read and Delete Speaker Notes in PowerPoint in Java

Delete Speaker Notes

import com.spire.presentation.*;

public class SpeakerNotes {
    public static void main(String[] args) throws Exception {
        //Load the PowerPoint document
        Presentation ppt = new Presentation();
        ppt.loadFromFile("SpeakerNotes.pptx");

        //Get the first slide
        ISlide slide = ppt.getSlides().get(0);

        //Delete all speaker notes from the note slide
        slide.getNotesSlide().getNotesTextFrame().getParagraphs().clear();

        //Save the document
        ppt.saveToFile("DeleteSpeakerNotes.pptx", FileFormat.PPTX_2013);
    }
}

Add, Read and Delete Speaker Notes in PowerPoint in Java