Changing Style Font

I am trying to change the font type of the styles in a document. This is what I’ve got so far:

Document doc = new Document("DocumentName");
foreach(Style style in doc.Styles)
{}

I can’t seem to figure it out. I found many examples of doing this in the forums but nothing I can use.
For example I found style.getFont().setName(fontName) which seemed promising but getfont() and setname() are not available to me.

This message was posted using Aspose.Live 2 Forum

Hi Bill,
You may be able to use the code from this thread to achieve what you are looking for
https://forum.aspose.com/t/75158
If you need to change the font in the styles then you could use the example code below.

for (int i = 0; i <doc.getStyles().getCount(); i++)
{
    Style style = doc.getStyles().get(i);
    if (style.getFont() != null)
    {
        style.getFont().clearFormatting();
        style.getFont().setSize(20);
        style.getFont().setName("Arial");
    }
}

Thanks,

Hi Bill,

Thanks for your request. The code example provided by Adam is in Java. As I can see you are using C#, so, just in case, here is the same code in C#:

foreach(Style style in doc.Styles)
{
    if (style.Font != null)
    {
        style.Font.ClearFormatting();
        style.Font.Size = 20;
        style.Font.Name = "Arial";
    }
}

Best regards.