You need something like this:
StyleSheet st = new StyleSheet();
st.LoadTagStyle("body", "face", "Tahoma");
st.LoadTagStyle("body", "encoding", "Identity-H");
List<IElement> htmlarraylist = HTMLWorker.ParseToList(new
StringReader(html), st);
Paulo
----- Original Message -----
From: Anvar Ramazanov
To: [email protected]
Sent: Thursday, June 23, 2011 10:00 AM
Subject: [iText-questions] Problems with cyrilic fonts in html tags
Hello! I have a problem with cyrilic font in html tag. Some tags displyed
cyrilic content correctly, some tags don't displyed this content
Sample:
Document document = new Document(PageSize.A4, 42, 53, 70, 46);
BaseFont baseFont =
BaseFont.CreateFont(Environment.ExpandEnvironmentVariables(@"%systemroot%\fonts\Tahoma.TTF"),"CP1251",
BaseFont.EMBEDDED);
Font font = new Font(baseFont, Font.DEFAULTSIZE, Font.NORMAL);
string path = Server.MapPath("PDF") + "/Doc.pdf";
PdfWriter.GetInstance(document, new FileStream(path,
FileMode.Create));
document.Open();
string html= @" <h1>Это заголовок уровня 1!</h1> // in this
tags content displayed
<p>А это новый абзац</p> // in this
tags content displayed
<p><b>Полужирный</b></p> // in this
tags content not displayed
<ul> // in bulleted list content dont displayed
(just a numbers)
<li> Это маркированный список 1
<li> Это маркированный список2
</ul>
//in table cyrilic content don't displayed
<table border='1'>
<tr>
<td align='right'> Ячейка 1</td>
<td align='right'> Ячейка 2</td>
</tr> </table>
</html>";
List<IElement> htmlarraylist = HTMLWorker.ParseToList(new
StringReader(html), null);
Paragraph myparagraph = new Paragraph("", font);
foreach (IElement str in htmlarraylist)
myparagraph.Add(str);
document.Add(myparagraph);
Paragraph Rus = new Paragraph("Тестирование", font);
document.Add(Rus);
document.Close();
I don't know whats i do wrong. Please help me
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
iText-questions mailing list
[email protected]
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