Free Support Forum - aspose.com

How to get the font size and text of each textbox/shape based on Vb.net

Hi,support:

Is there any way to get the font size and text of each textbox/shape based on Vb.net?

Thanks for your help!

@ducaisoft,

Please consider using following example on your end.

Public Shared Sub ExtractFontInfo()
    Dim pres As Presentation = New Presentation("Test.pptx")

    For Each slide As ISlide In pres.Slides

        For Each shape As IShape In slide.Shapes

            If TypeOf shape Is IAutoShape Then
                Dim ashp As IAutoShape = CType(shape, IAutoShape)

                If ashp.TextFrame IsNot Nothing Then
                    Dim textFrame As ITextFrame = ashp.TextFrame

                    For Each para As IParagraph In textFrame.Paragraphs

                        For Each portion As IPortion In para.Portions
                            Console.WriteLine("Text is: " & portion.Text)

                            If portion.PortionFormat IsNot Nothing Then
                                Console.WriteLine("Font Size: " & portion.PortionFormat.FontHeight)
                                Console.WriteLine("Font Name: " & portion.PortionFormat.LatinFont.FontName)
                            End If
                        Next
                    Next
                End If
            End If
        Next
    Next
End Sub