When converting a html file with Persian content, the result does not contain appropriate Persian content. All Persian content shows as ???
Asked
Active
Viewed 723 times
2

Nic
- 12,220
- 20
- 77
- 105

Masoud Bahrami
- 111
- 1
- 12
2 Answers
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
-
1Yes but this is not effect on the pdf file – Masoud Bahrami Mar 07 '15 at 07:59
-
It seams, Pdf has problem with Persian and Arabic Content – Masoud Bahrami Dec 05 '15 at 12:43
-
2019 and still problem exists – Omar N Shamali Nov 24 '19 at 14:43
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