Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
iTextSharp is not inserting special characters (serbian letters: P,Š,Đ,Č,Ć,Ž) into PDF Form. Can you please help me with editing my code to fix that issue. Thanks in advance.

What I have tried:

This is my code:

C#
private void BtnSaglasnost_Click(object sender, EventArgs e)
        {
            IzlistajImenaPolja();
            PopuniFormu();
        }

        private void IzlistajImenaPolja()
        {
            string pdfTemplate = @"C:\UDDKT\PDF\Saglasnost.pdf";

            this.Text += " - " + pdfTemplate;

            PdfReader pdfReader = new PdfReader(pdfTemplate);
        }

        private void PopuniFormu()
        {
            string pdfTemplate = @"C:\UDDKT\PDF\Saglasnost.pdf";
            string newFile = @"C:\UDDKT\PDF\Saglasnost_Popunjena.pdf";
            PdfReader pdfReader = new PdfReader(pdfTemplate);
            PdfStamper pdfStamper = new PdfStamper(pdfReader,
                new FileStream(newFile, FileMode.Create));
            AcroFields pdfFormFields = pdfStamper.AcroFields;

            pdfFormFields.SetField("FrmIme", TxtIme.Text);
            pdfFormFields.SetField("FrmPrezime", TxtPrezime.Text);
            pdfFormFields.SetField("FrmBrojLK", TxtBrojLK.Text);
            pdfFormFields.SetField("FrmDatum", TxtDatumAkcije.Text);

            pdfStamper.FormFlattening = false;

            pdfStamper.Close();
        }
Posted
Updated 2-Nov-19 5:38am
Comments
Richard MacCutchan 31-Oct-19 12:25pm    
I think you need to tell the form which font must be used to display those characters.

 
Share this answer
 
Comments
Maciej Los 2-Nov-19 11:23am    
5ed!
As far as i know, you need to use a font which is able to display serbian characters. See: iTextSharp - Working with Fonts[^]

More:
Display Chinese Characters in PDF created by iTextSharp[^]
Generate PDF with different encodings using iTextSharp[^]
 
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