Click here to Skip to main content
15,886,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
DataTable dt = new DataTable();
BaseFont baseFont = BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") + @"\fonts\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
iTextSharp.text.Font font = new iTextSharp.text.Font(baseFont, 10, 0);
dt.Columns.Add("Тарифен број, Type.GetType("System.String"));
dt.Columns.Add("Количина", Type.GetType("System.String"));
dt.Columns.Add("Вредност", Type.GetType("System.String"));
dt.Columns.Add("давачки", Type.GetType("System.String"));
for (int i = 0; i < 15; ++i)
{
dt.Rows.Add();
dt.Rows[i]["Тарифен број"] = (i + 1).ToString();
dt.Rows[i]["Количина"] = "Item " + i.ToString();
dt.Rows[i]"Вредност"] = (i + 1).ToString();
dt.Rows[i]["Давачки"] = (i + 2).ToString();

}
this.dataGridView1.DataSource = dt;
}


private void btnExportPdf_Click(object sender, EventArgs e)
{
int count = 0;
int Total = 0;
int Total2 = 0;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
BaseFont baseFont2 = BaseFont.CreateFont(Environment.GetEnvironmentVariable("windir") + @"\fonts\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
iTextSharp.text.Font font1 = new iTextSharp.text.Font(baseFont2, 10, 0);

Font ColFont = new iTextSharp.text.Font(font1);
Chunk chunkCols = new Chunk(dataGridView1.Columns[1].ToString(), ColFont);
count = Convert.ToInt32(dataGridView1.Rows[i].Cells["Тарифен број / Артикл (Шифра, Назив)"].Value);
Total += Convert.ToInt32(dataGridView1.Rows[i].Cells["Вредност на материјали"].Value);
Total2 += Convert.ToInt32(dataGridView1.Rows[i].Cells["Давачки на раздолжување"].Value);
When i create pdf file Cyrillic letters don't show on file.
Posted
Updated 18-Jun-15 9:36am
v3

1 solution

It's just that PDF default encoding is stupid CP-1252. (A shame, isn't it?) You need to specify that you need to use Unicode.

Please see the answer here: http://stackoverflow.com/questions/10329863/display-unicode-characters-in-converting-html-to-pdf[^].

Ви посакувам успех!
—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900