I am using following code to convert html to pdf.But arabic is not showing when pdf generated.What is the problem with the following code.
//Create a byte array that will eventually hold our final PDF
Byte[] bytes;
using (var ms = new MemoryStream())
{
FontFactory.Register(Server.MapPath("~/fonts/TRADBDO.TTF"));
using (var doc = new Document())
{
using (var writer = PdfWriter.GetInstance(doc, ms))
{
doc.Open();
var example_html = @"<p>This <em>is البرامج الدراسية المطروحة البرامج الدراسية المطروحةالبرامج الدراسية المطروحةالبرامج الدراسية المطروحةالبرامج الدراسية المطروحةالبرامج الدراسية المطروحة</em>55555<span class=""headline"" style=""text-decoration: underline;"">some</span> <strong>sample <em> text</em></strong><span style=""color: red;"">!!!</span></p>";
var example_css = @".headline{font-size:200%}";
FontFactory.Register(Server.MapPath("~/fonts/TRADBDO.TTF"));
using (var msCss = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(example_css)))
{
using (var msHtml = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(example_html)))
{
iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, msHtml, msCss);
}
}
doc.Close();
}
}
bytes = ms.ToArray();
}
var testFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test_123_345.pdf");
System.IO.File.WriteAllBytes(testFile, bytes);