I am try to create marathi PDF using iTextSharp PDF is created successfully but marathi text are improper
expecting result अंदाजपत्रकातील तरतूद व खर्च but getting data अंदाजपत् रकातील तरतुद व खरच
code
public void pdf() {
string pdfFileName = Request.PhysicalApplicationPath + "\\PDF\\" + "GenerateHTMLTOPDF.pdf";
FileStream fs = new FileStream(pdfFileName, FileMode.Create);
Document doc = new Document(PageSize.LETTER);
PdfWriter writer = PdfWriter.GetInstance(doc, fs);
doc.Open();
//Path to our font
string mangalTff = Request.PhysicalApplicationPath + "\\font\\" + "mangal.ttf";
//Register the font with iTextSharp
iTextSharp.text.FontFactory.Register(mangalTff);
//Create a new stylesheet
iTextSharp.text.html.simpleparser.StyleSheet ST = new iTextSharp.text.html.simpleparser.StyleSheet();
//Set the default body font to our registered font's internal name
ST.LoadTagStyle(HtmlTags.BODY, HtmlTags.FACE, "mangal");
//Set the default encoding to support Unicode characters
ST.LoadTagStyle(HtmlTags.BODY, HtmlTags.ENCODING, BaseFont.IDENTITY_H);
//Parse our HTML using the stylesheet created above
string htmlDisplayText = Convert.ToString(HTMLReport());
htmlDisplayText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Unicode, Encoding.Unicode, Encoding.UTF8.GetBytes(htmlDisplayText)));// html
List<IElement> list = HTMLWorker.ParseToList(new StringReader(htmlDisplayText), ST);
//Loop through each element, don't bother wrapping in P tags
foreach (var element in list){
doc.Add(element);
}
doc.Close();
Response.ContentType = "application/x-download";
Response.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", "GenerateHTMLTOPDF.pdf"));
Response.ContentEncoding = Encoding.UTF8;
Response.WriteFile(pdfFileName);
Response.HeaderEncoding = Encoding.UTF8;
Response.Flush();
Response.End();
}
advance thank you