I am using itextsharp dll to convert HTML to PDF.
The HTML has some Unicode characters like α, β... when I try to convert HTML to PDF, Unicode characters are not sho
private class UnicodeFontFactory : FontFactoryImp
{
private BaseFont _baseFont;
public UnicodeFontFactory()
{
string FontPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "arialuni.ttf");
_baseFont = BaseFont.CreateFont(FontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
}
public override Font GetFont(string fontname, string encoding, bool embedded, float size, int style, BaseColor color, bool cached)
{
return new Font(_baseFont, size, style, color);
}
}
//and Code
FontFactory.FontImp = new UnicodeFontFactory();
string convertedHtml = string.Empty;
foreach (char c in htmlText)
{
if (c < 127)
convertedHtml += c;
else
convertedHtml += "" + (int)c + ";";
}
List htmlElements = XMLWorkerHelper.ParseToElementList(convertedHtml, null);
// add the IElements to the document
foreach (IElement htmlElement in htmlElements)
{
document.Add(htmlElement);
}