Изменение шрифта только для определенных символов Unicode при сохранении в PDF

Пример

На следующем скриншоте сравниваются два выходных PDF-файла, сгенерированных примерным кодом ниже.

Один сгенерирован без установки свойства PdfSaveOptions.IsFontSubstitutionCharGranularity, а другой - с установкой свойства PdfSaveOptions.IsFontSubstitutionCharGranularity в true.

Как видно на первом PDF, шрифт всего предложения изменился с Times New Roman на Arial Unicode MS из-за Non-Breaking Hyphen. В то время как на втором PDF, изменился только шрифт Non-Breaking Hyphen.

Первый файл PDF
todo:image_alt_text
Второй файл PDF
todo:image_alt_text

Образец кода

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Create workbook object
Workbook workbook = new Workbook();
// Access the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Access cells
Cell cell1 = worksheet.Cells["A1"];
Cell cell2 = worksheet.Cells["B1"];
// Set the styles of both cells to Times New Roman
Style style = cell1.GetStyle();
style.Font.Name = "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" + Convert.ToChar(8209) + " with Non-Breaking Hyphen");
// Autofit the columns
worksheet.AutoFitColumns();
// Save to Pdf without setting PdfSaveOptions.IsFontSubstitutionCharGranularity
workbook.Save(dataDir + "SampleOutput_out.pdf");
// Save to Pdf after setting PdfSaveOptions.IsFontSubstitutionCharGranularity to true
PdfSaveOptions opts = new PdfSaveOptions();
opts.IsFontSubstitutionCharGranularity = true;
workbook.Save(dataDir + "SampleOutput2_out.pdf", opts);