Cambie la fuente solo en los caracteres Unicode específicos mientras guarda en PDF

Ejemplo

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

Uno se genera sin establecer la propiedad PdfSaveOptions.IsFontSubstitutionCharGranularity y el otro se generó después de establecer la propiedad PdfSaveOptions.IsFontSubstitutionCharGranularity en verdadero.

Como puede ver en el primer PDF, la fuente de la oración completa ha cambiado de Times New Roman a Arial Unicode MS debido a Non-Breaking Hyphen. Mientras que en el segundo PDF, solo ha cambiado la fuente de Non-Breaking Hyphen.

Primer archivo PDF
todo:imagen_alternativa_texto
Segundo archivo PDF
todo:imagen_alternativa_texto

Código de muestra

// 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);