Gembox.document: How to set the custom font of the whole document before saving.
I have to process find & replace and it works fine. But before saving I want to change & set the custom font of the whole document irrespective of area/section/block etc.
I tired using: document.DefaultCharacterFormat.FontName = “Verdana”
but this does not work
Note: The custom font is installed in Windows & registered.
Changing the default font will only work for elements that specify the font neither directly nor on its style.
If you’re interested in learning about how formatting is inherited in document elements, then check this Style Resolution example.
Anyway, try using this:
var document = DocumentModel.Load("input.docx");
foreach (Run run in document.GetChildElements(true, ElementType.Run))
run.CharacterFormat.FontName = "Verdana";
document.Save("output.docx");