Specify Default Fonts
Contents
[
Hide
]
See more details in the Manipulating and Substitution TrueType Fonts article.
We have a simple program which allows to convert a Word document to PDF. This is achieved by loading the document into the Aspose.Words document model (DOM) and calling the Save method with a “.PDF” extension.
You can specify the default font by calling the DefaultFontName property before the document is rendered.
The following code example shows how to specify default fonts:
Document doc = new Document("../../data/document.doc");
// If the default font defined here cannot be found during rendering then the closest font on the machine is used instead.
FontSettings.DefaultInstance.SubstitutionSettings.DefaultFontSubstitution.DefaultFontName = "Arial Unicode MS";
// Now the set default font is used in place of any missing fonts during any rendering calls.
doc.Save("Rendering.SetDefaultFont_Out.pdf");
doc.Save("Rendering.SetDefaultFont_Out.xps");
See also:
- GitHub for running code