قم بتغيير الخط على أحرف Unicode المحددة فقط أثناء الحفظ في PDF
لا يمكن عرض بعض أحرف Unicode بواسطة الخط المحدد من قبل المستخدم. أحد هذه الأحرف Unicode هوواصلة غير فاصلة (U + 2011) ورقم Unicode الخاص به هو 8209. لا يمكن عرض هذا الحرف معتايمز نيو رومان ، ولكن يمكن عرضها مع خطوط أخرى مثلArial Unicode MS.
عند ظهور مثل هذا الحرف داخل بعض الكلمات أو الجمل الموجودة بخط معين مثل Times New Roman ، فإن Aspose.Cells يغير خط الكلمة أو الجملة بأكملها إلى الخط الذي يمكن أن يعرض هذا الحرف مثل Arial Unicode إلى MS.
ومع ذلك ، يعد هذا سلوكًا غير مرغوب فيه لبعض المستخدمين ويريدون فقط تغيير خط الحرف المحدد بدلاً من تغيير خط الكلمة أو الجملة بأكملها.
للتعامل مع هذه المشكلة ، يوفر Aspose.Cells خاصية PdfSaveOptions.IsFontSubstitutionCharGranularity التي يجب تعيينها على صواب بحيث لا يتم تغيير سوى خط الحرف المحدد غير القابل للعرض إلى الخط القابل للعرض وبقية الكلمة أو الجملة في الخط الأصلي.
مثال
تقارن لقطة الشاشة التالية بين ملفي PDF الناتج اللذين تم إنشاؤهما بواسطة نموذج التعليمات البرمجية أدناه.
يتم إنشاء أحدهما بدون تعيين خاصية PdfSaveOptions.IsFontSubstitutionCharGranularity والآخر تم إنشاؤه بعد تعيين خاصية PdfSaveOptions.IsFontSubstitutionCharGranularity إلى true.
كما ترى في ملف Pdf الأول ، تم تغيير خط الجملة بالكامل من Times New Roman إلى Arial Unicode MS بسبب الواصلة غير الفاصلة. بينما في ملف PDF الثاني ، تم تغيير خط Non-Breaking Hyphen فقط.
أول ملف PDF |
---|
![]() |
ملف PDF الثاني |
---|
![]() |
عينة من الرموز
// 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); |