PDF'e kaydederken Yazı Tipini yalnızca belirli Unicode karakterlerinde değiştirin

Contents
[ ]

Örnek vermek

Aşağıdaki ekran görüntüsü, aşağıdaki örnek kod tarafından oluşturulan iki çıktı PDF’sini karşılaştırır. Biri ayar yapılmadan oluşturulduPdfSaveOptions.setFontSubstitutionCharGranularity() özellik ve diğeri ayarlandıktan sonra oluşturulduPdfSaveOptions.setFontSubstitutionCharGranularity() mülkiyetdoğru. İlk PDF’de görebileceğiniz gibi, Non-Breaking Tire nedeniyle tüm cümlenin yazı tipi Times New Roman’dan Arial Unicode MS’ye değişmiştir. İkinci PDF’de ise sadece Kırılmaz Tire’nin yazı tipi değişti.

yapılacaklar:resim_alternatif_metin

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(ChangeFontonspecificUnicodecharacters.class);
// Create workbook object
Workbook workbook = new Workbook();
// Access the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
// Access cells
Cell cell1 = worksheet.getCells().get("A1");
Cell cell2 = worksheet.getCells().get("B1");
// Set the styles of both cells to Times New Roman
Style 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" + (char) (8209) + " with Non-Breaking Hyphen");
// Autofit the columns
worksheet.autoFitColumns();
// Save to Pdf without setting PdfSaveOptions.IsFontSubstitutionCharGranularity
workbook.save(dataDir + "output.pdf");
// Save to Pdf after setting PdfSaveOptions.IsFontSubstitutionCharGranularity to true
PdfSaveOptions opts = new PdfSaveOptions();
opts.setFontSubstitutionCharGranularity(true);
workbook.save(dataDir + "output2.pdf", opts);