Croatian letters in iTextSharp

我是研究僧i 提交于 2019-12-24 00:17:06

问题


I'm still a beginner in C# and I want to know is there an option of writing slavic letters č,ć,š,ž in PDF using iTextSharp. I was reading other posts about it but I can't apply their solution to my problem, maybe it's a bit to complicate to me as a beginner. This is my code:

SaveFileDialog pdfFile = new SaveFileDialog();
pdfFile.Filter = "PDF|*.pdf";
pdfFile.Title = "Spremi PDF";
pdfFile.FileName = "Ispit";
if (pdfFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
    Document document = new Document(iTextSharp.text.PageSize.LETTER, 25, 25, 35, 35);
    PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(pdfFile.FileName, FileMode.Create));
    document.Open();

    foreach (List<string> question in questions)
    {
          document.NewPage();
          foreach (string field in question)
          {
                 document.Add(new Paragraph(field));
          }
    }

    document.Close();
}

This code is maybe to simple and maybe there's a lots of better ways to do this but this is one of my first codes in C#.


回答1:


I have solved my problem. This is the code that helped me:

BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1250, false);
Font titleFont = new Font(bf,20);
Font infoFont = new Font(bf,16);

Thank you all



来源:https://stackoverflow.com/questions/33699295/croatian-letters-in-itextsharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!