How to Read Text Style Information from Presentation Defaults in C#?

I’m trying to read text style information and could use some help.

In the native XML file of a slide I can find something like

<p:txBody>
    <a:bodyPr wrap="square" rtlCol="0">
        <a:noAutofit/>
    </a:bodyPr>
    <a:lstStyle/>
    <a:p>
        <a:pPr marL="742950" lvl="1" indent="-285750" algn="ctr" defTabSz="914217">
            <a:buFont typeface="Arial" panose="020B0604020202020204" pitchFamily="34" charset="0"/>
            <a:buChar char="•"/>
        </a:pPr>
        <a:r>
            <a:rPr lang="en-US" dirty="0">
                <a:solidFill>
                    <a:srgbClr val="999999"/>
                </a:solidFill>
            </a:rPr>
            <a:t>Text here.</a:t>
        </a:r>
    </a:p>
</p:txBody>

Note the attribute lvl="1" and no sz attribute.

To understand the effective text size, I would look into the file presentation.xml to find

<p:defaultTextStyle>
    ...
    <a:lvl2pPr marL="457200" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
        <a:defRPr sz="1800" kern="1200">
            <a:solidFill>
                <a:schemeClr val="tx1"/>
            </a:solidFill>
            <a:latin typeface="+mn-lt"/>
            <a:ea typeface="+mn-ea"/>
            <a:cs typeface="+mn-cs"/>
        </a:defRPr>
    </a:lvl2pPr>
</p:defaultTextStyle>

How can I obtain the same information from the Aspose objects? In Aspose.Slides.ParagraphFormat I could not find the indentation level. And in Aspose.Slides.Presentation I see Aspose.Slides.TextStyle DefaultTextStyle but it does not carry information about lvl1pPr to lvl9pPr.

@co213,
Thank you for contacting free support. I am working on the issue and will get back to you soon.

1 Like

@co213,
Thank you for your patience. To get a text style level from a PowerPoint presentation, please try using the following code snippet:

IParagraphFormat paragraphFormat0 = presentation.DefaultTextStyle.GetLevel(0);
IParagraphFormat paragraphFormat1 = presentation.DefaultTextStyle.GetLevel(1);
// ...

More examples: Text Formatting|Aspose.Slides Documentation

Thanks for clarifying! I realize that my mistake was to only review the properties but in fact the method GetLevel matters. In Presentation.DefaultTextStyle.GetLevel(1).DefaultPortionFormat.FontHeight I found the requested value. And from Paragraph.ParagraphFormat.Depth I can read the indentation level.

Reviewing the documentation again I now figured out that I don’t even need to look up the default paragraphs using own code. I should simply use IPortionFormat.GetEffective().

@co213,
Yes, you are right. Using the GetEffective method you can extract the text portion format properties that are finally applied to the text. We are glad you found the solution.