When i am converting html to pdf in C# the arabic text is broken and also seems to be reversed. I have tried direction rtl, adding arabic fonts.
.arabic { direction: rtl; unicode-bidi: isolate; font-family: 'NotoNaskhArabic', sans-serif; } @@font-face { font-family: 'NotoNaskhArabic'; src: url('C:/Users/fahad.a/Downloads/NotoNaskhArabic-Regular.ttf') format('truetype'); } <td class="tdh" style="font-family: 'NotoNaskhArabic', sans-serif;">Date<span class="arabic" id="arabic" style="display:none; direction: rtl !important; font-family: 'NotoNaskhArabic', sans-serif;"><br>تاريخ الطلب</span></td> ConverterProperties properties = new ConverterProperties();
FontProvider fontProvider = new FontProvider(); fontProvider.AddStandardPdfFonts();
fontProvider.AddFont("C:/Users/fahad.a/Downloads/NotoNaskhArabic-Regular.ttf"); // Ensure the path is correct fontProvider.AddFont("C:/Users/fahad.a/Downloads/NotoKufiArabic-Regular.ttf"); // For bold text, if needed properties.SetFontProvider(fontProvider); properties.SetCharset("UTF-8"); // Ensure UTF-8 charset to handle Arabic script
// Add default styles properties.SetCssApplierFactory(new DefaultCssApplierFactory());
iText.Kernel.Pdf.PdfWriter writer = new iText.Kernel.Pdf.PdfWriter(destination, new WriterProperties().SetFullCompressionMode(true)); iText.Kernel.Pdf.PdfDocument pdfDocument = new iText.Kernel.Pdf.PdfDocument(writer);
//iText.Kernel.Font.PdfFont f = PdfFontFactory.CreateFont("/fonts/NotoSansMyanmar-Regular.ttf", PdfEncodings.IDENTITY_H, true);
HtmlConverter.ConvertToPdf(htmltrimmed, pdfDocument, properties);


