I have used this code and its converting English Text with and without formatting but doesn't respect Arabic Text so after converting it, pdf file is blank. RichTextBox rtbnew = new RichTextBox(); rtbnew.Rtf = this.rtb.Rtf; //string str = rtbnew.Rtf; String abc = "<body> " + this.markupConverter.ConvertRtfToHtml(rtbnew.Rtf) + " </body>"/*this.markupConverter.ConvertRtfToHtml(rtbnew.Rtf)*/; MessageBox.Show(abc); //rtbnew.Text = this.rtb.Text; //string str = rtbnew.Text; //TextReader tr = new StringReader(str); Document doc = new Document(); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(@path + "/Doc2.pdf", FileMode.Create)); ////////////////// doc.Open(); //Sample HTML StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(@" <body> " + abc + " </body>");
//Path to our font //string arialuniTff = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF"); //Register the font with iTextSharp //BaseFont bfArialUniCode = BaseFont.CreateFont(@"fonts\\ARIALUNI_2.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); iTextSharp.text.FontFactory.Register(@"C:\Users\M.Shahid.Sultan\Documents\Visual Studio 2010\Projects\PDFGeneration\bin\Debug\fonts\ARIALUNI_2.TTF"); //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, "Arial Unicode MS"); //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 List<IElement> list = HTMLWorker.ParseToList(new StringReader(stringBuilder.ToString()), ST); MessageBox.Show(list.ToString()); //Loop through each element, don't bother wrapping in P tags foreach (var element in list) { //MessageBox.Show(element.ToString()); doc.Add(element); } doc.Close(); Can somebody tell me whether is it font problem or encoding scheme mess? -- View this message in context: http://itext-general.2136553.n4.nabble.com/Arabic-text-is-not-being-shown-in-pdf-tp4658775.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php