iTextSharp-PDF不显示外来字符

时间:2020-01-24 14:25:33

标签: winforms pdf

我有一个Form 3,其中的文本框和标签用字符“ěščřžýáíé”书写,并且在iTextSharp中创建PDF时(完成的PDF文件) 没有显示所需的字符“ěščřžýáíé”,该空格为空。如果以英语列出,则效果很好。 请,如何编辑代码以能够正确“读取”标签和文本框。 现在,我已将标签更改为“文本框”,但是我不知道如何显示字符“ěščřžýáíé”并创建包含字符..p的PDF。

鳕鱼样本:

using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "PDF file|*.pdf", ValidateNames = true })
            {
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    iTextSharp.text.Document doc = new iTextSharp.text.Document (PageSize.A4.Rotate());
                    try
                    {   
                        PdfWriter.GetInstance(doc, new FileStream(sfd.FileName, FileMode.Create));
                        doc.Open();
                        doc.Add(new iTextSharp.text.Paragraph(textBox4.Text));
                        doc.Add(new iTextSharp.text.Paragraph(cisloTextBox.Text));
                        doc.Add(new iTextSharp.text.Paragraph(textBox5.Text));
                        doc.Add(new iTextSharp.text.Paragraph(prijmeniComboBox.Text));
                        doc.Add(new iTextSharp.text.Paragraph(textBox6.Text));
                        doc.Add(new iTextSharp.text.Paragraph(zaznamTextBox.Text));
                        doc.Add(new iTextSharp.text.Paragraph(textBox7.Text));
                        doc.Add(new iTextSharp.text.Paragraph(poznamkaTextBox.Text));
                        doc.Add(new iTextSharp.text.Paragraph(textBox10.Text));
                        doc.Add(new iTextSharp.text.Paragraph(telefonTextBox.Text));
                        doc.Add(new iTextSharp.text.Paragraph(textBox9.Text));
                        doc.Add(new iTextSharp.text.Paragraph(emailTextBox.Text));
                        doc.Add(new iTextSharp.text.Paragraph(textBox8.Text));
                        doc.Add(new iTextSharp.text.Paragraph(oznameniComboBox.Text));
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        doc.Close();
                    }

                }
    }
}

0 个答案:

没有答案