Specify Individual or Private Set of Fonts for Workbook Rendering with Node.js via C++

Possible Usage Scenarios

Generally, you specify the fonts directory or list of fonts for all workbooks, but sometimes you have to specify an individual or private set of fonts for your workbooks. Aspose.Cells for Node.js via C++ 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

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 for the custom font directory.
const fontConfigs = new AsposeCells.IndividualFontConfigs();

// If you comment this line, or if the custom font directory is wrong, or
// if it does not contain the required font, then the 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);