Difficulties getting text out using slides

Hi,

We have loaded an existing slide presentation and then we are looping through per the code fragment below. I cant get text out. What is wrong here/ Thanks.

For Each shape In oSlide.Shapes
If Not shape.TextFrame Is Nothing Then
Dim tf As TextFrame
Dim para As New Paragraph

Dim j As Integer
For j = 0 To oSlide.Placeholders.Count - 1
Dim holder As Placeholder = oSlide.Placeholders(j)
tf = shape.TextFrame

For Each para In tf.Paragraphs
If holder.PlaceholderType = PlaceholderType.CenteredTitle1 Or holder.PlaceholderType = PlaceholderType.CenteredTitle2 Or holder.PlaceholderType = PlaceholderType.Title Then
SlideTitle = SlideTitle & tf.Text & vbCrLf
End If

If holder.PlaceholderType = PlaceholderType.Body Then
SlideText = SlideText & para.Text & vbCrLf
End If
Next

Next
End If

Next

I’m not sure I understand what you trying to do. If you want to extract
text from all placeholders only, you should check if placeholder is
textholder (class TextHolder is subclass of Placeholder) and if it is,
cast it to Textholder and get Paragraphs from it. By the way, if you
don’t need formatting, you can get all text of a
TextFrame/TextHolder as one string using Text property.

Sorry but this truely is not working for me and I have coded it 100 different ways. Please provide a sample that simply gets the text out of a slide - just need titles and body items.

Following code dumps TextHolders’ text:



Module Module1



Sub Main()

Dim pres As Aspose.Slides.Presentation = New Aspose.Slides.Presentation(“file.ppt”)

Dim slide As Aspose.Slides.Slide

Dim dentry As DictionaryEntry

Dim textholder As Aspose.Slides.TextHolder



For Each slide In pres.Slides

For Each dentry In slide.Placeholders

If TypeOf dentry.Value Is Aspose.Slides.TextHolder Then

textholder = CType(dentry.Value, Aspose.Slides.TextHolder)

System.Console.Out.WriteLine("{0} = {1}", textholder.PlaceholderType,
textholder.Text)

End If

Next



Next

End Sub



End Module

I just created a clean test file webform1.aspx in .net, and literally copied and pasted your code into the code behind of Page_Load and of course, provided a path to a 58 slide presentation.

On the first slide,

If TypeOf dentry.Value Is Aspose.Slides.TextHolder Then

evaluates true and we get some text. But for all of the following slides this statement evaluates to false.

So this does not work. Please help.

This condition should be false when there is no any text in placeholder (in Powerpoint this looks like default text, such as “Title” and so on). Maybe text on other slides stored in textframes? If problem still exists please send us problematic presentation, we’ll investigate this issue.

I just did some more tests and the problem appears to be more of how we are iterating through the slides in the presentation. I also added a test for textframe

The following code outputs text from a presentation but it skips many of the slides. Please tell us what we are doing wrong here. If this code appears reasonable, please provide an FTP to send the test PowerPoint (13.5mb) to.

Function iterate_thru_slide_text(ByVal filename As String)
Dim pres As Aspose.Slides.Presentation = New Aspose.Slides.Presentation(filename)
Dim slide As Aspose.Slides.Slide
Dim textholder As Aspose.Slides.TextHolder
Dim i As Integer
Dim slide_count As Integer

slide_count = pres.Slides.Count


For i = 0 To slide_count - 1
slide = pres.Slides.Item(i)
Dim iterator As IDictionaryEnumerator = slide.Placeholders.GetEnumerator()
While iterator.MoveNext()
If TypeOf iterator.Value Is TextHolder Or TypeOf iterator.Value Is TextFrame Then
Dim th As TextHolder = CType(iterator.Value, TextHolder)
Dim para As Paragraph
For Each para In th.Paragraphs
Response.Write(“BODY:” & th.PlaceholderType.ToString & " " & para.Text & “
”)
Next

End If
End While
Next

End Function

Here is some additional information -

The code I just posted gets the title for slide 1, then skips to slide 44 and processes most, but not all of the slides at the end of the presentation.

Slides 5-8 in our presentation have very standard centered titles and then several bullet points of text.
In debug mode, I stepped over the lines of code and for those slides, the test on iterator.value is false even though there is definitely text in there.

Please zip your presentation and send to tyumen@aspose.com
The size is doesn’t matter.

Hi,

Just emailed this to you. Please confirm you recieved it as its a big file. Thanks.

I didn’t get it yet. Please contact me with any instant messanger, I will give you another email
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactTyumen.html

I dont IM, I will try again with the same email using yahoo mail instead of our mail server which tends to be balky with big files.

I just sent another email to you at the original address with a version of the same presentation with many graphics taken out. I retested and the issue stil exists. I also included my code in the zip. Please let me know that you received this. Thanks.

I sent solution with code example by email.
Hope it can help you.

Many thanks for your patience and guidance. We finally have a solution.