How to Set a Default Font in GemBox.Document

GemBox.Document is a great help when you need to work with Microsoft Office documents in .Net. It gives you one simple interface to interact with DOCX, DOC, PDF, PDF/A, HTML, XPS, RTF, TXT and XML files – all without the hassle of Office interop objects.

We use GemBox for nearly every output we produce in our applications. We start with one or more Word templates and add the content with C#. That helps us to fulfil the corporate design guidelines without much effort.

As long as all the templates you want to combine to a document use the same default font, GemBox works as expected. However, if one template uses a different default font, your combined document may end up with a mix of fonts far beyond the wrong template. Should this happen with your document, you can set a default font that will be used throughout the document:

The font you set on the DocumentModel instance will override all default fonts in your document, but it does not change the parts where you set an explicit font. That gives you a consistent looking document without interfering with the parts that should be different.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.