facebooktwittermenuarrow-up

GemBox Support Forum

How to set font family to Arial with HtmlLoadOptions()

Currently am using below code to get my value in html format:

contentControl.Content.LoadText(sowTemplateField.value,
    new HtmlLoadOptions() { InheritCharacterFormat = true,InheritParagraphFormat=true });

How to set the font family to Arial to above HtmlLoadOptions.

Any help on this would be great.

Hi,

You can specify the Arial font in your HTML content.
For example, you could add something like this to your sowTemplateField.value content:

<style>
* { font-family: Arial; }
</style>

Or you can iterate through Run elements inside the content control after loading the HTML content.
For example, like this:

foreach (Run run in contentControl.GetChildElements(true, ElementType.Run))
    run.CharacterFormat.FontName = "Arial";

I hope this helps.

Regards,
Mario