Specify Individual or Private Set of Fonts for Workbook Rendering

Possible Usage Scenarios

Generally, you specify the fonts directory or list of fonts for all workbooks but sometimes, you have to specify individual or private set of fonts for your workbooks. Aspose.Cells provides IndividualFontConfigs class that can be used to specify the individual or private set of fonts for your workbook.

Specify Individual or Private Set of Fonts for Workbook Rendering

The following sample code loads the sample Excel file with its individual or private set of fonts which are specified using the IndividualFontConfigs class. Please see the sample font used inside the code as well as the output PDF generated by it. The following screenshot shows how the output PDF looks if the font is found successfully.

todo:image_alt_text

Sample Code

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Path of your custom font directory.
string customFontsDir = "C:\\TempDir\\CustomFonts";
// Specify individual font configs custom font directory.
IndividualFontConfigs fontConfigs = new IndividualFontConfigs();
// If you comment this line or if custom font directory is wrong or
// if it does not contain required font then output pdf will not be rendered correctly.
fontConfigs.SetFontFolder(customFontsDir, false);
// Specify load options with font configs.
LoadOptions opts = new LoadOptions(LoadFormat.Xlsx);
opts.FontConfigs = fontConfigs;
// Load the sample Excel file with individual font configs.
Workbook wb = new Workbook("sampleSpecifyIndividualOrPrivateSetOfFontsForWorkbookRendering.xlsx", opts);
// Save to PDF format.
wb.Save("outputSpecifyIndividualOrPrivateSetOfFontsForWorkbookRendering.pdf", SaveFormat.Pdf);