How do I get the font size of text in a shape through openxml?

1k Views Asked by At

I am trying to check the size of a text in shape in a powerpoint presentation through openXML but I am not sure how to get it, since it is a RunProperty.

Does somebody know how to get it? I already know how to get the font and the color of the font, could I maybe do it similar to this?

IEnumerable<Drwng.LatinFont> fonts = textShape.Descendants<Drwng.LatinFont>();
foreach (Drwng.LatinFont font in fonts)
{
    paragraphText.Append(font.Typeface.Value);
}
String writtenFont = paragraphText.ToString();
1

There are 1 best solutions below

0
On BEST ANSWER

I found a way to do it. But if you know a better way, I'm always happy to improve my code. Especially since I'm not very happy with my solution. Even though it works fine:

// textShape is the shape that I am looking at
// "Drwng" being Drwng = DocumentFormat.OpenXml.Drawing;
int writtenFontSize = 0;
foreach (var run in textShape.Descendants<Drwng.RunProperties>()) 
{
    writtenFontSize = run.FontSize; 
}