Problem extracting notes from a slide

I’m doing the following to extract the notes:

ISlide slide = oPres.Slides[i];
INotesSlide mynotes = slide.NotesSlide;
if (mynotes != null && mynotes.NotesTextFrame.Text != “”)
String text = mynotes.NotesTextFrame.Text;

However, mynotes is always null. I have verified the presentation and I have notes.

What am I doing wrong?

Thanks.


Hi,

I have observed the sample code shared and request you to please try using the following sample code on your end to extract the text. If there is still an issue then please share the sample presentation causing issue on your end and I will investigate that further on my end to help you out.

public static void getNotes()
{
Presentation pres = new Presentation(“Test.pptx”);

ISlide slide = pres.Slides[0];

INotesSlide note = slide.NotesSlide;

if (note != null)
{
foreach (IShape shape in note.Shapes)
{
if (shape is IAutoShape)
{
IAutoShape ashp = (IAutoShape)shape;

if (ashp.TextFrame != null)
{
String text = ashp.TextFrame.Text;
}
}
}
}

}

Many Thanks,

Thanks for your reply. I tried your suggestion but it doesn’t work completely.
It returns the notes text, but it also returns some other text that I don’t know where it comes from.

For example, if you try the attached presentation, it will retrieve “These are my notes” and "1"
I don’t know where “1” comes from.

Thanks

Hi,

I like to share that Slide notes have shapes with placeholder type image, body and slide number. The only one with the text is Body placeholder. I have modified the sample code to serve your need. Please try using the following sample code to serve the purpose.

public static void getNotes()
{
String path = @“D:\Aspose Data”;
Presentation pres = new Presentation(path+“a.ppt”);

ISlide slide = pres.Slides[0];

INotesSlide note = slide.NotesSlide;

if (note != null)
{
foreach (IShape shape in note.Shapes)
{
if (shape is IAutoShape && shape.Placeholder.Type==PlaceholderType.Body)
{
IAutoShape ashp = (IAutoShape)shape;

if (ashp.TextFrame != null)
{
String text = ashp.TextFrame.Text;
}
}
}
}

}

Many Thanks,

Thanks. It works now!