指定工作簿渲染的个体或私有字体集
Contents
[
Hide
]
可能的使用场景
通常,你为所有工作簿指定字体目录或字体列表,但有时,你必须为工作簿指定单独或私有字体集。Aspose.Cells for Python via .NET 提供了IndividualFontConfigs类,可用于为你的工作簿指定单独或私有字体集。
指定工作簿渲染的个体或私有字体集
以下示例代码使用 IndividualFontConfigs 类指定了样本 Excel 文件及其单独或专用的字体集。 请在代码中查看所使用的样本字体以及由此生成的输出 PDF。 以下屏幕截图显示了如果成功找到字体时输出 PDF 的外观。
示例代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |