Cambiar la fuente solo en caracteres Unicode específicos al guardar en PDF con Node.js a través de C++

Ejemplo

La siguiente captura de pantalla compara los dos PDF generados por el código de muestra a continuación.

Una se genera sin configurar la propiedad PdfSaveOptions.isFontSubstitutionCharGranularity y la otra después de establecerla en true.

Como se puede ver en el primer PDF, la fuente de toda la frase cambió de Times New Roman a Arial Unicode MS debido al guion no separable. Mientras que en el segundo PDF, solo cambió la fuente del guion no separable.

Primer archivo PDF
todo:image_alt_text
Segundo archivo PDF
todo:image_alt_text

Código de muestra

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");

// Create workbook object
const workbook = new AsposeCells.Workbook();

// Access the first worksheet
const worksheet = workbook.getWorksheets().get(0);

// Access cells
const cell1 = worksheet.getCells().get("A1");
const cell2 = worksheet.getCells().get("B1");

// Set the styles of both cells to Times New Roman
let style = cell1.getStyle();
style.getFont().setName("Times New Roman");
cell1.setStyle(style);
cell2.setStyle(style);

// Put the values inside the cell
cell1.putValue("Hello without Non-Breaking Hyphen");
cell2.putValue("Hello" + String.fromCharCode(8209) + " with Non-Breaking Hyphen");

// Autofit the columns
worksheet.autoFitColumns();

// Save to Pdf without setting PdfSaveOptions.IsFontSubstitutionCharGranularity
workbook.save(path.join(dataDir, "SampleOutput_out.pdf"));

// Save to Pdf after setting PdfSaveOptions.IsFontSubstitutionCharGranularity to true
const opts = new AsposeCells.PdfSaveOptions();
opts.setIsFontSubstitutionCharGranularity(true);
workbook.save(path.join(dataDir, "SampleOutput2_out.pdf"), opts);