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 for Python via .NET 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.
Sample Code
from aspose.cells import IndividualFontConfigs, LoadFormat, LoadOptions, SaveFormat, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Path of your custom font directory. | |
customFontsDir = "C:\\TempDir\\CustomFonts" | |
# Specify individual font configs custom font directory. | |
fontConfigs = 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.set_font_folder(customFontsDir, False) | |
# Specify load options with font configs. | |
opts = LoadOptions(LoadFormat.XLSX) | |
opts.font_configs = fontConfigs | |
# Load the sample Excel file with individual font configs. | |
wb = Workbook("sampleSpecifyIndividualOrPrivateSetOfFontsForWorkbookRendering.xlsx", opts) | |
# Save to PDF format. | |
wb.save("outputSpecifyIndividualOrPrivateSetOfFontsForWorkbookRendering.pdf", SaveFormat.PDF) |