Node.jsとC++を使用したワークブックのフォントの個別またはプライベートセットの指定方法
Contents
[
Hide
]
可能な使用シナリオ
通常、すべてのワークブックに対してフォントディレクトリまたはフォントのリストを指定しますが、場合によっては、個別またはプライベートなフォントセットを指定する必要があります。Aspose.Cells for Node.js via C++は、ワークブック用に個別またはプライベートなフォントセットを指定できるIndividualFontConfigsクラスを提供します。
ワークブックのレンダリング用に個々またはプライベートなフォントセットを指定する
以下のサンプルコードは、IndividualFontConfigsクラスを使用して個別またはプライベートなフォントセットを持つサンプルExcelファイルをロードします。コード内で利用されるサンプルフォントと、それによって生成される出力PDFも参照してください。スクリーンショットでは、フォントが正常に見つかった場合の出力PDFの見た目です。

サンプルコード
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// Path of your custom font directory.
const customFontsDir = "C:\\TempDir\\CustomFonts";
// Specify individual font configs custom font directory.
const fontConfigs = new AsposeCells.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.
const opts = new AsposeCells.LoadOptions(AsposeCells.LoadFormat.Xlsx);
opts.setFontConfigs(fontConfigs);
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sampleSpecifyIndividualOrPrivateSetOfFontsForWorkbookRendering.xlsx");
// Output directory
const outputDir = path.join(__dirname, "output");
// Load the sample Excel file with individual font configs.
const wb = new AsposeCells.Workbook(filePath, opts);
// Save to PDF format.
wb.save(outputDir + "outputSpecifyIndividualOrPrivateSetOfFontsForWorkbookRendering.pdf", AsposeCells.SaveFormat.Pdf);