ワークブックのレンダリング用に個々またはプライベートなフォントセットを指定する

可能な使用シナリオ

通常、すべてのワークブックに対してフォントディレクトリまたはフォントのリストを指定しますが、時には個別またはプライベートなフォントセットをワークブックに指定する必要があります。Aspose.Cellsは、IndividualFontConfigsクラスを提供し、これを使用してワークブックに個別またはプライベートなフォントセットを指定することができます。

ワークブックのレンダリング用に個々またはプライベートなフォントセットを指定する

以下のサンプルコードは、IndividualFontConfigsクラスを使用して指定されたワークブックの個々またはプライベートなフォントセットを読み込みます。コード内で使用されているサンプルフォント(67338302.zip)およびそれによって生成された出力PDF(67338303.pdf)も参照してください。次のスクリーンショットは、フォントが正常に見つかった場合の出力PDFの外観を示しています。

todo:image_alt_text

サンプルコード

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// 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.setFontConfigs(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);