2

When converting a html file with Persian content, the result does not contain appropriate Persian content. All Persian content shows as ???

Nic
  • 12,220
  • 20
  • 77
  • 105
Masoud Bahrami
  • 111
  • 1
  • 12

2 Answers2

2

Are you starting your HTML with:

<!DOCTYPE html>    
<html>
    <head>
        <meta charset="utf-8">

Also ensure that the Persian fonts are installed locally.

Nic
  • 12,220
  • 20
  • 77
  • 105
0

now you can solve your problem by using itext7.pdfhtml and itext7.pdfcalligraph. install them using NuGet manager, and use this method to convert your Persian or Arabic Html to pdf :

public static void ConvertHtmlToPDF(string Html)
{
        ConverterProperties properties = new ConverterProperties();
        FontProvider fontProvider = new DefaultFontProvider();
        properties.SetFontProvider(fontProvider);

        PdfWriter writer = new PdfWriter(new FileStream(PDFFileAddressTobeGenerated, FileMode.Create));
        PdfDocument pdfDocument = new PdfDocument(writer);

        HtmlConverter.ConvertToPdf(htmlFile, pdfDocument, properties);
}
Farzad Karimi
  • 770
  • 1
  • 12
  • 31