We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to extract text from PPTX?

For PPT format we extract text objects on the slide as such:

foreach (Aspose.Slides.Shape s in slide.Shapes)
{
if (s.TextFrame != null)
{
string msg = s.TextFrame.Text;
if (!String.IsNullOrEmpty(msg))
{
txtContent.Append(msg);
txtContent.Append(" “);
}
}
}

and we extract the present notes like this:

if (slide.Notes != null && !String.IsNullOrEmpty(slide.Notes.Text))
{
txtContent.Append(slide.Notes.Text);
txtContent.Append(” ");
}


The APIs seem to have changed for PPTX where we can no longer do this. Could you please advise?

Regards,

Stefan






Hi Stefan,

Here is an example for pptx.

foreach (ShapeEx shape in shapes)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

{

if (shape is AutoShapeEx)

{

AutoShapeEx autoShp = (AutoShapeEx)shape;

if (autoShp.TextFrame != null)

Response.Write(autoShp.TextFrame.Text);

}

else if (shape is TableEx)

{

TableEx table = (TableEx) shape;

foreach (RowEx row in table.Rows)

{

foreach (CellEx cell in row)

{

if (cell.TextFrame != null)

Response.Write(cell.TextFrame.Text);

}

}

}

}

Could you kindly supply this code for VB?

Hi Eric,


Thanks for your interest in Aspose.Slides.

Please use the following VB converted code snippet for your kind reference.

For Each s As Aspose.Slides.Shape In slide.Shapes
If s.TextFrame IsNot Nothing Then
Dim msg As String = s.TextFrame.Text
If (Not String.IsNullOrEmpty(msg)) Then
txtContent.Append(msg)
txtContent.Append(" “)
End If
End If
Next s

If slide.Notes IsNot Nothing AndAlso (Not String.IsNullOrEmpty(slide.Notes.Text)) Then
txtContent.Append(slide.Notes.Text)
txtContent.Append(” ")
End If


For Each shape As ShapeEx In shapes
If TypeOf shape Is AutoShapeEx Then
Dim autoShp As AutoShapeEx = CType(shape, AutoShapeEx)
If autoShp.TextFrame IsNot Nothing Then
Response.Write(autoShp.TextFrame.Text)
End If
ElseIf TypeOf shape Is TableEx Then
Dim table As TableEx = CType(shape, TableEx)
For Each row As RowEx In table.Rows
For Each cell As CellEx In row
If cell.TextFrame IsNot Nothing Then
Response.Write(cell.TextFrame.Text)
End If
Next cell
Next row
End If
Next shape
End Sub


Many Thanks,